jeudi 17 juin 2021

How to loop to an if Statement outside of the while loop

I am a complete noob in python and I am trying to make an text- based adventure game to have an overview of my knowledge. I am trying to move to IF statement outside of a loop without defining a function. Is there a way to do that or not?

def first_choice():
print("You have two choices. There is a town in right of you. It is a small town as you can see it from far away and in front of you, there is a tavern\n")
movement = input('If you want to go to town, type RIGHT or if you want to go tavern, type TAVERN:\n ').lower()
time.stop = 1
if movement == 'right':
    print("You are now in the center of the town now. Town's center is empty.\n ")
    movement = input('If you want to go back to first choices, type BACK: \n').lower()
    time.stop = 0.5
    while True:
        if movement == 'back':
            first_choice()
        else:
            print(invalid) # Here I want to go back to above if statement after 'right' input

Aucun commentaire:

Enregistrer un commentaire