I wanted to make a program that takes the inventory as a dictionary data and prints it with the total at the bottom.
# inventory.py
stuff = {"coal":42,"dagger":1,"iron":
20,"torch":2}
total_items = 0
def display_inventory(inventory):
for k,v in inventory.items():
print(k,v)
global total_items
total_items = total_items + v
print("\n")
print("Total: " + str(total_items))
I want to add colon to output like: coal: 42 dagger: 2 How do i do this?
Edit: We call the function using the variable "stuff"