How do I make the game loop back to the beginning after the user has died

118 views Asked by At

#adventure game When the user enters the wrong room and die I want it to go back to the question of what room to enter

prompt = print("You are in a room by yourself. There are three doors; Red, Blue, and Green. Which door are you picking")
user = input("Room?: ")


def red():
    print("You enter the red room and die")
def blue():
    print("You enter the blue room and freeze to death")
def green():
    print("You enter the green room and proceed")

if user == "r":
        red()
        print(prompt)
elif user == "b":
        blue()
        print(prompt)
elif user == "g":
        green()
        print(prompt)
1

There are 1 answers

3
John Gordon On

Wrap the logic in a while True loop.

As long as you don't break out of the loop, it will keep repeating.