samedi 2 avril 2016

How to make my python code loop back

I'm really new to python and I'm attempting to learn by making a simple game. I want the user to be able to input their action, then if they chose not too continue, they will be sent back to the stage of inputting again. I've attempted this as best I can but once they choose not to "continue", they can no longer choose any of the other options I've set out.

Help is appreciated.

print ("How do you proceed?")
print ("Do you Shout? Look? Continue?")
action1 = input()

if action1 == ("Continue"): #Continue to next section
    print ("You continue on throught the darkness untill you reach a cold stone wall")
    pass

elif action1 == "Shout":
    print ("In the dark noone can hear you scream.")

elif action1 == ('Look'):
    print ("'I cannae see anything in the dark' you think to yourself in a braod Scottish accent.")

while action1 != ("Continue"):
    print ("Enter your next action.(Case sensitive!!)")
    print ("Shout? Look? Continue?")
    action1 = input() #Want this too loop back to start of action menu

Aucun commentaire:

Enregistrer un commentaire