1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Python] Why does my user-input repeat all the questions? [closed]

Discussão em 'Python' iniciado por Stack, Setembro 28, 2024 às 05:52.

  1. Stack

    Stack Membro Participativo

    while True
    game2=input("Welcome to Treasure island! Your mission is to find the treasure. You find two different paths. Left or Right?")
    if str(game2)==str("right"):
    print("GAME OVER! You fell down a hole")
    elif str(game2)==str("left"):
    print("CONGATULATIONS! You made it")
    print("You are being chased by an angry mob of monkeys. What do you do? Give them a banana or hide?")
    if str(game2)==str("give them a banana"):
    print("GAME OVER! You didnt have enough bananas")
    elif str(game2)==str("hide"):
    print("CONGRATULATIONS! You made it")
    print("You found an old abandond cabin. Do you go in?")
    if str(game2)==str("no"):
    print("GAME OVER! You were eaten by a hungry bear")
    elif str(game2)==str("yes"):
    print ("CONGRATULATIONS! You got away from the forest")
    print("You find three doors 1,2,and 3. Which do you pick?")
    if str(game2)==str("1"):
    print("GAME OVER! You fell into a dark pit")
    elif str(game2)==str("3"):
    print("GAME OVER! The room was filled with toxic gas")
    elif str(game2)==str("2"):
    print("You chose the right door")
    print("You found a dark room with three treasure chests inside. You can only open one. Which do you pick 1,2,or 3?")
    if str(game2)==str("3"):
    print("GAME OVER! The treasure chest was filled with spiders")
    elif str(game2)==str("2"):
    print("GAME OVER! You opened an empty treasure chest")
    elif str(game2)==str("1"):
    print ("CONGRATS, YOU FOUND THE TREASURE!!")


    The first question comes by itself as normal, then the rest of the questions come all together. I tryed removing the while true loop but it still comes all together. When i add else, it prints that too.

    Continue reading...

Compartilhe esta Página