I am coding a text based adventure game and I am currently working on an inventory system this is the code I have:
Inventory=[]
Combat code
A=random.randint(1, 10)
B=random.randint(1, 10)
If a=b:
Print('enemy dropped wheat')
Additem('wheat')
Def additem(item):
Inventory.append(item)
For I in inventory:
Print(i)
I want to make it so that if I had two wheat it would print 2 wheat not wheat wheat
The code I tried is:
inventory=[]
def additem(item):
Inventory.append(item)
def removeitem(item):
Inventory.remove
Additem('wheat')
Additem('wheat')
for wheat in inventory:
removeitem('wheat')
Additem(wheat + 'wheat')
For I in inventory:
Print(i)
I expected it to print: 2 wheat but it printed: Wheatwheat Wheatwheatwheat