-2

My Code

print("Hello World")
print("How're you?")
mood = input()
print("I'm " + mood + " too")
print("What's your name?")
name = input()
print(name + ". I really like that name!")
food = input("I really like pizza. Do you? Y/N ")
if food == 'y' or 'Y':
    print("Wow! " + name + ", you and I have a really similar taste in food, don't we? So what else do you like?")
elif food == 'n' or 'N':
    print("Oh, that's a shame. I was gonna treat us to a cheeky Papa Johns!")
else:
    print("Oh! Okay. Then what else do you like?")
other = input()
if other == 'liquorice' or 'Liquorice' or 'Brussels Sprouts' or 'brussels sprouts':
    print("Blegh! " + name + ", I respect you and all... but gross!")

Output

I'm trying to make the program use the ELIF and ELSE outputs when I type in something other than Y or y (standing for yes). What do I need to do to fix this error?

1 Answers1

0

When you use

if food =='y' or 'Y':

the python will return true all the time, you can test this:

if 'false':
    print('true')

To make it work, replace food =='y' or 'Y' with either food =='y' or food=='Y' or as suggested by @Peter Wood, use the lower/upper of the food

U3.1415926
  • 812
  • 12
  • 30