-
Notifications
You must be signed in to change notification settings - Fork 0
/
restaurant.py
50 lines (40 loc) · 1.11 KB
/
restaurant.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
def restaurant():
"""
This function takes orders from customer and displays the
running total.
@param: None
@return int - total
"""
# Initialize variables.
menu = {'egusi': 150,
'akpu': 150,
'onugbu': 200,
'okro': 150,
'garri': 150,
'nsala': 300,
'rice': 150,
'stew': 150,
'isiewu': 1000
}
total = 0.0
print()
# Request input from user. Exit program if blank line is entered.
while True:
order = input("Order: ").strip().lower()
if not order:
break
# Check if customer order is available in the menu. Increment total
# if order is available and display appropriate message.
if order in menu:
total += menu[order]
print(f'{order} cost {menu[order]}, total is {total}')
else:
print(f'Sorry, we are fresh out of {order} today.')
# print(f'Your total is {total}')
return total
def main():
# Ask user for the order and display approriate message.
print(f'Your total is {restaurant()}')
print()
# Driver function.
main()