0

so I've been experimenting with learning python recently. Mostly by just making random cool fun terminal based projects to get my feet wet. And as of right now I'm attempting to create a silly little game with my partner, its a text based adventure one. And I'm struggling with if statements with inputs. My goal is to have the user say Yes or No to progress the story in certain ways. But it only ever seems to follow the first If path.

reply = input("Do you wish to help the man?: ")
if reply == "Yes" or "yes":
    print("The man thanks you and gives you a single gold piece.")
else:
    print("You turn your back from the man as his voice slowly fades in the distance.")

Output

Do you wish to help the man?: no
The man thanks you and gives you a single gold peice.

Some help would be greatly apricated; and please use simple terms as I'm very new to coding as a whole. Only picking it up recently.

Park
  • 2,446
  • 1
  • 16
  • 25
Xanthus
  • 55
  • 1
  • 9
  • Try changing the if statement to `if reply.lower() == 'yes':` and see if that helps your case. You can also do `if reply == 'Yes' or reply == 'yes':` or `if reply in ['Yes', 'yes']:` – zedfoxus Feb 18 '22 at 04:30
  • 2
    Does this answer your question? [How to test multiple variables for equality against a single value?](https://stackoverflow.com/questions/15112125/how-to-test-multiple-variables-for-equality-against-a-single-value). The second `'yes'` simply evaluates to True. You need to have `reply == 'yes'` after `or` for it to check. – shriakhilc Feb 18 '22 at 04:30

0 Answers0