CommitmentIssues
CommitmentIssues

Reputation: 7

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

#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)

Upvotes: -1

Views: 128

Answers (1)

John Gordon
John Gordon

Reputation: 33359

Wrap the logic in a while True loop.

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

Upvotes: 0

Related Questions