-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpurchased-item-tracker.py
39 lines (36 loc) · 1.31 KB
/
purchased-item-tracker.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
# Initialize an empty list to store purchased items
purchased_items = []
# Function to add an item to the purchased_items list
def add_item():
name = input("Enter the item name: ")
price = float(input("Enter the item price: "))
quantity = int(input("Enter the quantity purchased: "))
purchased_items.append({'Name': name, 'Price': price, 'Quantity': quantity})
print("Item added successfully!")
# Function to display the summary of all purchased items
def display_summary():
print("\n--- Purchased Items Summary ---")
total_cost = 0
for item in purchased_items:
print("Name:", item['Name'])
print("Price:", item['Price'])
print("Quantity:", item['Quantity'])
print("------------------------")
total_cost += item['Price'] * item['Quantity']
print("Total Cost: ", total_cost)
print("------------------------")
# Main program loop
while True:
print("1. Add an item")
print("2. Display purchased items summary")
print("3. Quit")
choice = input("Enter your choice (1-3): ")
if choice == '1':
add_item()
elif choice == '2':
display_summary()
elif choice == '3':
print("Thank you for using the travel item tracker. Have a great day!")
break
else:
print("Invalid choice. Please try again.\n")