0

I'm new to coding and while I was doing an assignment for my teacher I was trying to make my if statement accepts two options for the conditional.

  choice = input("What type of sandwich would you like today?\nYour options are: Chicken - $5.25, Beef - $6.35, or Tofu - $5.75 ")
if choice == ('Chicken' and 'chicken'):
    print('You chose Chicken for $5.25.')
    sandwich_total=(5.25)
    confirm=input('Are you sure this is what you want? Y/N ')
    if confirm == ('Y'):
        print('Okay...')
    elif confirm ==('N'):
        intro()

The idea is that it would accept either chicken lower-cased or Chicken upper-cased and to me it would make sense if it accepted or but it doesn't...It accepts and. The way I was taught and would only work if both conditions are true while or would only work if one of the conditions were true but when I use or it finishes the code.

Damian
  • 78
  • 3
Jpods
  • 1
  • Go open a Python shell and play around typing only `'Chicken' and 'chicken'`, and with `or`. This does not do what you think it does. And neither would it make sense. “Does this string equal this string *and* that string?” It can’t equal two different strings at once. – deceze Apr 01 '21 at 05:46
  • Hi there, simply it's not that `AND` works instead of `OR` (`AND` does NOT work indeed). You have a logic error in your code :). Think about the line `if choice == ('Chicken' and 'chicken'):` further... – dswij Apr 01 '21 at 06:00

0 Answers0