mardi 5 juillet 2016

Set a attempt limit to failures in Python 3>

So I am making a basic text-adventure for a school project and was wondering if I can set "lives" to the story so after so many times the game ends and the player must start anew.

For example:

choose == input ("""You must choose between the left door and the right door, which do you choose? l/r
    :""")

if choose == "l":
    print ("You open the door and get the money! congrats!")
    quit()
else:
    ("You open the door and are eaten by a evil goblin! you die!")
    quit()

What I would like to do for this is for the second option (r) you loose one out of three (or any number) lives. But of course it would have to work throughout the whole story and would be implemented into every choice. I would also need to display (if they guess the wrong thing) how many lives they have left. If anyone would be willing to help me that would be great.

Aucun commentaire:

Enregistrer un commentaire