dimanche 3 juillet 2016

Python 3.X jumping to a line of code


I'm trying to make a Choose Your Own Adventure game in Python 3.X. I'm using the idle platform. Here is a sample of my code.

import time
again = True  
while again == True:  
    print("You wake up as you normally do, but something's not quite right. What will be the first thing you do? n Choices: n Go back to sleep n Get up")  
    action1 = input(": ")  
    if action1 == "Go back to sleep":  
        print("You lazyhead. As you were about to fall asleep, your ceiling collapsed on you and killed you. Don't be lazy.")  
    playAgain = input("Play again? Y/N: ")  
    if playAgain == "Y":  
        again = True  
    elif playAgain == "N":  
        again = False   

Obviously, there is stuff between action1 and playAgain. I want to replace again = false in elif playAgain =="N"

elif playAgain =="N":
    again = false

I want to instead jump to playAgain so I don't just end the program. This is my first question so my formatting is probably a bit weird so please correct that too.


Aucun commentaire:

Enregistrer un commentaire