Mar-26-2020, 10:23 AM
Hi
Im new to Python but have programmed in Basic many many years ago.
Im trying to help my daugther with her Python homework, and for the life of me i dont understand why this If statement doesnt evaluate properly.
Could someone generously provide some help into why this simple program doesnt print "Ghost" when bth ghost_door and door_num are the same values.
Im sure its is something really simple but im stuck.
Best regards
Andy
Im new to Python but have programmed in Basic many many years ago.
Im trying to help my daugther with her Python homework, and for the life of me i dont understand why this If statement doesnt evaluate properly.
Could someone generously provide some help into why this simple program doesnt print "Ghost" when bth ghost_door and door_num are the same values.
import random
print("Ghost Game")
feeling_brave=True
score=0
while feeling_brave == True:
ghost_door=random.randint(1,3)
print("Three doors ahead")
print("A ghost behind one")
print("Which door do you open?")
door_num=input("1, 2, or 3? ")
print("ghost door",ghost_door) #test
print("Door num",door_num) #test
if ghost_door == door_num:
print("Ghost!")
feeling_brave = False
else:
print("No ghost!")
print("You enter the next room.")
score = score + 1
print("Run Away!")
print("Game over! You scored",score)Thankyou in adavance.Im sure its is something really simple but im stuck.
Best regards
Andy
