-3
import time

repeat=0
price=0
print("Welcome to McDonald's self order system")
time.sleep(0.5)
name_person=str(input("\nPlease enter your name to continue: "))
while True:
    order=int(input("\n---Menu---\n 1.Burger\n 2.McPuff\n 3.Ice Cream\n 4.Cold Drink\n\nPlease order by typing the number: "))
    if order in range(1,4) :
        repeat=str(input("Do you want to order more? Yes/No: "))
        if repeat == "No" or "no":
            print("Ok")
            break
    else :
        print("\n!!Invalid input!!")
        time.sleep(0.5)

The or command is not working when I am typing No it shows Ok that's normal but if I type Yes it should loop but then also it's showing Ok and when I am typing anything it's giving the output Ok but if I am removing the or its working perfectly.

martineau
  • 119,623
  • 25
  • 170
  • 301
  • That's not how `or` works. `or` is for values where one value may be empty or not exist so you add an `or` after it for a known value that does exist. – OneMadGypsy Jul 22 '22 at 13:35

1 Answers1

1

Instead of if repeat == "No" or "no", use:

if repeat == "No" or repeat == "no"

Or even:

if repeat in ("No", "no")
The Thonnu
  • 3,578
  • 2
  • 8
  • 30
  • 3
    No need to answer this when there are two direct duplicates posted in the comments. – gmdev Jul 22 '22 at 13:35
  • 3
    @OneMadGypsy Compare this answer to the accepted one in the [dup](https://stackoverflow.com/a/20002504/669576). This one contains a fraction of the information. It's a distraction. OP should be directed to the best answer - which is not this one. – 001 Jul 22 '22 at 13:46