-1

I'm starting a class on Python, and an assignment was to create a knock knock joke. I wanted to take it one step further, so I tried this code:

jokesetup=input('Do you want to hear a joke? Yes/No:')

if jokesetup=="yes" or "Yes": knockknock=input('Knock knock')

if jokesetup=="no" or "No": print('Then why are you here?')

But if I answer Yes or No, it still just says "Knock knock". What have I done wrong?

Thank you!

chepner
  • 497,756
  • 71
  • 530
  • 681
  • `a == "b" or "B"` is the same as `(a == "b") or "B"`. You want `a in ("b", "B")` or `a == "b" or a == "B"` – Bakuriu Jul 02 '20 at 18:48

1 Answers1

0
if jokesetup=="yes" or "Yes"

This means True as "Yes" is not an empty string.

You have to compare jokesetup with "Yes" also.

if jokesetup=="yes" or jokesetup=="Yes"

Boolean in Python: https://www.w3schools.com/python/python_booleans.asp

Vishal Dhawan
  • 351
  • 3
  • 9