Python help please


#1



This code just won't run properly. Please help. When I input 1, it prints out an extra line of code:

"You trip over a rock and fall into a pool of lava. Good job!"


print("You enter a dark room with two doors. Do you go through door #1 or door #2?")

door = input()

if door != "1" or "2":
   print("You trip over a rock and fall into a pool of lava. Good job!")
    
if door == "1":
    print("There is a fat walrus eating lime jello. What do you do?")
    print("1. Take the jello.")
    print("2. Throw a rock at the walrus.")

    fear = input()

    if fear == "1":
        print("The walrus gores you in the face with his tusks. Good job!")
    elif fear == "2":
        print("The walrus rolls on top of you and squishes you. Good job!")
    else:
        print("Well, doing %s is probably better. The walrus runs away." %fear)
   
if door == "2":
    print("You look into the endless abyss of Thor's navel.")
    print("1. Purple elephant fins.")
    print("2. kumquats.")
    print("3. Smelling your own ear.")

    insanity = input()

    if insanity == "1" or insanity == "2":
        print("You feel your body melt off your spinal column. Good job!")
    elif insanity == "3":
        print("You survive, but as a toadstool forever gathering lint. Good job!")


input("\n\nPress the enter key to exit.")









Replace this line with your code.


#2

door = input()

you are taking a value as integer but for checking use string

1 and '1' not same

and you can't check condition like

door != "1" or "2"

you have to check both side same way

also you've more than one condition then use elif after if


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.