0

I am trying to create a function that accepts 5, 10, and 25 as input, re-prompting the user if one of those numbers is not inputted.

def get_paid(y):
    while True:
        n = int(input("Insert Coin: "))
        if n != 5 or 10 or 25:
            print(f"Amount Due: {y}")
            continue
        else:
            break
    return n

However, no matter what input is given it is stuck in the loop and doesn't break. If I only set it to 5, it works.

def get_paid(y):
    while True:
        n = int(input("Insert Coin: "))
        if n != 5:
            print(f"Amount Due: {y}")
            continue
        else:
            break
    return n

How can I set it so if n is 5, 10, or 25 it will break?

bwags
  • 1
  • 1

1 Answers1

0
if n != 5 or 10 or 25:

must be spelled as

if n != 5 or n != 10 or n != 25:

-- or more pythonically as

if n not in (5, 10, 25):
AKX
  • 152,115
  • 15
  • 115
  • 172