Okay, here's the thing.
input() ends when Enter is hit.
i.e. - if you type "coffee water" and then press enter, it's gonna think that's the name of the item you're entering. ("coffee water")
Basically, enter one item at a time.
Or, if you want, split by whitespace and support the addition of multiple items at the same time. something like:
dictionary = {}
value = input("Enter item: ")
while value !="":
value = value.split(" ") # split by space.
# if there's no space (i.e. only one item is entered this time, this gives a list with a single item in it. (the word entered)
for item in value:
if item in dictionary.keys(): # if the item exists, add 1 to its counter
dictionary[item] +=1
else: # if the item doesn't exist, set its counter to 1
dictionary[item] = 1
value = input("Enter item: ")
for key, value in sorted(dictionary.items()):
print(value, key.upper())
Entering:
coffee
water
water coffee
gives:
2 COFFEE
2 WATER
Note: this breaks if you have items with spaces in their name. like "water bottle"
also read about the defaultdict module