Error in the below program

typdict = {}

while True:
    try:
        food = input().upper()
        if food not in dict:
            dict[food] = 1
        else:
            dict[food] +=1
    except EOFError:
        break
    lst = sorted(dict.items())
    for k,v in lst:
        print(v,k)e or paste code here

Expected output should be, If i type mango and press enter then enter strawberry press enter,it should be display,
1 MANGO
1 STRAWBERRY.
but above program gives me the output, inputted mango and press enter its gives me 1 MANGO
help please

Thank you so much, i want enter mango and strawberry then i want the output
1 MANGO
1 STRAWBERRY, i try to change the code.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.