0

I am creating a text-based adventure game in Python, but I'm having problems with my if-statements and printing the correct outcome. If the user types "yes," then both outcomes are printed and the same thing happens if the user types "no." All help is appreciated.

def main():
    playerLvl = 0

    treatOne = input("You find a Hershey's Bar on the floor while you are trick-or-treating. Would you like to collect the Hershey's Bar? Type yes or no.")
    print("You chose: ", treatOne, "!")

    if treatOne == "yes" or "Yes":
         playerLvl += 1
         print("Good choice! You gained points for picking up candy. Now your score is: ", playerLvl)

    if treatOne == "no" or "No":
        playerLvl -= 1
        print("Uh oh. You lost points. You're supposed to pick up candy for points. Now your score is:", playerLvl)

    else:
        print("Error. Try again.")
main()
Edric
  • 24,639
  • 13
  • 81
  • 91
  • 2
    Your problem is that you mean `if (treatOne == "yes") or (treatOne == "Yes"):` but wrote actually `if treatOne == ("yes" or "Yes"):` which is True for all non empty `treatOne`s - but you should do `if treatOne.lower() == "yes":` anyway... – SpghttCd Oct 31 '19 at 16:25
  • 1
    @Spghtt Correction, they actually wrote `if (treatOne == "yes") or "Yes":`, which is *always* true, regardless of the value of `treatOne`. – deceze Nov 01 '19 at 05:58

0 Answers0