for i in range(100):
inventory = ["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",]
a = input("--> ")
if a == "inventory":
print(inventory)
elif a == "add-item":
d = input("item-number--> ")
gus = input("item-name-->")
inventory.insert(d, gus)
print(inventory)
elif a == "terminate-item":
c = input("terminate--> ")
inventory.remove(c)
else:
print("no")
Asked
Active
Viewed 21 times
0

Andrej Kesely
- 168,389
- 15
- 48
- 91

AÜGÙŠTŪŚ MÆĮÈR
- 1
- 1
-
Every time through the loop you're resetting the inventory. The `inventory = [...]` line should be before the loop. – Barmar Apr 25 '23 at 21:47
-
Why are you initializing inventory to lots of empty strings? Why not an empty list, and use `append()` to add a new item to it? – Barmar Apr 25 '23 at 21:48
-
This code has nothing to do with files. – Barmar Apr 25 '23 at 21:50
-
thank you i needed help and you fixed it good job. – AÜGÙŠTŪŚ MÆĮÈR Apr 25 '23 at 21:58