-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path08-01-25(2).py
42 lines (35 loc) · 1.02 KB
/
08-01-25(2).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
def inventory_manager(d):
def update_item():
i = input("Enter item name to update: ")
p = float(input("Enter new price: "))
d[i] = p
def delete_item():
i = input("Enter item name to delete: ")
if i in d:
d.pop(i, None)
else:
print("\nItem not found.")
def print_items():
print("\nCurrent Inventory:")
for k, v in d.items():
print(f"{k}: {v}")
while True:
print("\nOptions:")
print("1. Update Price")
print("2. Delete Item")
print("3. Print All Items")
print("4. Exit")
choice = input("Choose an option (1-4): ")
if choice == "1":
update_item()
elif choice == "2":
delete_item()
elif choice == "3":
print_items()
elif choice == "4":
break
else:
print("Invalid choice. Try again.")
return d
inventory = {"apple": 12, "banana": 5, "cherry": 20}
inventory_manager(inventory)