samedi 5 décembre 2020

If else statement does not recognize the lists from input

I am learning how to make a text typed game in python. I could not get it to work. eventhough there is a water in my list (bag) it would still end the game eventhough i have it. Please help me

...
bag = [ ]
sword = ("sword")
water_bucket = ("water")
dead = False

ready = input("are you ready? ")
while dead == False:
    print("this is whats inside your bag ")
    print(bag)
    if ready == "yes":
        print("let's start our journey ")
        print(
            "It was a beautiful morning, you woke up in a dungeon, your quest is to find a dragon and slay his head off")
        while dead == False:
            if dead == True:
                break
            else:
                first = input("Choose a path front/back/left/right")
                if first == "front":
                    if bag == "water":
                        print(" You got safe because of the water bucket")
                    else:
                        dead = True
                        print(" You died in a hot lava")
                elif first == "back":
                    ask2 = input("There is a sword, do you want to take it?")
                    if ask2 == "yes":
                        bag.append(sword)
                        print("You got a sword")
                    elif ask2 == "no":
                        print("you did not take it and went back to start")
                    else:
                        print("please answer with yes or no")
                elif first == "left":
                    if bag == "sword":
                        print("You fought a dragon and win")
                    elif bag != "sword":
                        print("You fought a dragon but lost because you do not have a weapon")
                        dead = True
                elif first == "right":
                    ask3 = input("Water Buckets! might be helpful, take it? ")
                    if ask3 == "yes":
                        bag.append(water_bucket)
                        print("You got a water bucket")
                        print(bag)
                    elif ask3 == "no":
                        print("you did not take it and went back to start")
                    else:
                        print("please answer with yes or no")
                else:
                    print("not a path")
    else:
        print("See you next time, A journey awaits")
...

It is a text based im learning right now

Aucun commentaire:

Enregistrer un commentaire