Python Basics: Order Chicken

Asked 2 years ago, Updated 2 years ago, 16 views

# I'm practicing ordering chicken.
# Order = int("How many would you like to order?" : "))) indicates an identifying error.
# Can't I use the phrase "order"?
# Is it a code problem? Is it a program setting problem?

class SoldOutError(Exception):
    pass

chicken = 10
waiting = 1

while(True):
    try:
    Order = int("How many would you like to order?" : "))
    if Order <= 0:
        raise ValueError
    elif Order >= 10:
        raise SoldoutError
    else:
        print("{0} Chicken Order Completed" {1}Guest"\
            .format(Order, waiting))
        waiting += 1
        Order -= chicken

    if chicken == 0:
        raise SoldOutError
        break        

    except ValueError:
        print("Invalid value entered. Please enter a natural number.")
    except SoldOutError:
        print("No stock available" Thank you.")
        break

python

2022-09-20 19:07

1 Answers

Because it's chicken... I've checked Haha

class SoldOutError(Exception):
    pass

chicken = 10
waiting = 1
while(True):
    try:
        Order = int("How many would you like to order?" : "))
        if Order <= 0:
            raise ValueError
        elif Order > 10:
            Rise SoldOutError #Capital typos
        else:
            print("{0} Chicken Order Completed" {1}Guest"\
                .format(Order, waiting))

            waiting += 1
            chicken - = Order #Change Order
            print(f's leftover chicken:{chicken}')
        if chicken == 0:
            raise SoldOutError
            break        

    except ValueError:
        print("Invalid value entered. Please enter a natural number.")
    except :
        print(f"currently has {chicken} in stock. We're out of stock. Thank you.")
        break


2022-09-20 19:07

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.