forked from ishantk/GW2022PD1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSession8A.py
65 lines (51 loc) · 1.35 KB
/
Session8A.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
mc_donalds_menu = [
{
"name": "burger",
"price": 100,
"quantity": 0
},
{
"name": "fries",
"price": 70,
"quantity": 0
},
{
"name": "coke",
"price": 50,
"quantity": 0
},
{
"name": "pizza",
"price": 300,
"quantity": 0
},
{
"name": "noodles",
"price": 200,
"quantity": 0
}
]
def shoppin_cart():
# Shopping Cart
cart = []
total_amount = 0
total_dishes = 0
choice = "yes"
while choice == "yes":
dish_name = input("Enter Dish Name: ")
for idx in range(len(mc_donalds_menu)):
if mc_donalds_menu[idx]["name"] == dish_name:
quantity = int(input("Enter the Quantity for "+dish_name+" :"))
mc_donalds_menu[idx]["quantity"] = quantity
total_dishes += quantity
total_amount += quantity * mc_donalds_menu[idx]["price"]
cart.append(mc_donalds_menu[idx])
break
choice = input("Do You wish to continue (yes/no): ")
print("CART [", len(cart), "]")
print(cart)
print("Total Dishes:", total_dishes)
print("Please Pay: \u20b9:", total_amount)
return total_amount
result = shoppin_cart()
# Complete the journey of checkout by asking user to apply promo code :)