-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinventory_management.py
More file actions
50 lines (45 loc) · 1.43 KB
/
Copy pathinventory_management.py
File metadata and controls
50 lines (45 loc) · 1.43 KB
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
inventory = {}
def add():
item = input("Enter the item name to add: ")
copies = int(input("Enter the quantity: "))
if item in inventory:
inventory[item] += copies
else:
inventory[item] = copies
print("Item added successfully.\n", inventory)
def update():
item = input("Enter the item name to be updated: ")
if item in inventory:
copies = int(input("Enter the new quantity: "))
inventory[item] += copies
print("Given item is updated successfully.\n", inventory)
else:
print("This item does not exist.")
def remove():
item = input("Enter the item name to be removed: ")
if item in inventory:
del inventory[item]
print("Given item is removed successfully.\n", inventory)
else:
print("This item does not exist.")
def display():
print("The items in the inventory so for:\n", inventory)
def exiting():
print("Exiting Inventory Management.")
print("INVENTORY MANAGEMENT")
while True:
choice = int(input("\n1. Add\n2. Update\n3. Remove\n4. Display\n5. Exit\nEnter your choice number: "))
if choice == 1:
add()
elif choice == 2:
update()
elif choice == 3:
remove()
elif choice == 4:
display()
elif choice == 5:
exiting()
break
else:
print("Invalid choice.")
Print("The inventory at last:\n", inventory)