๐Ÿ“ฆ jasonbanboa / python

๐Ÿ“„ grocery.py ยท 22 lines
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22def lister():
    grocery = {}

    while True:
        try:
            item = input().strip().upper()
            if item not in grocery:
                grocery[item] = 1

            elif item in grocery:
                grocery[item] = grocery[item] + 1

        except EOFError:
            for stuff in sorted(grocery.keys()):
                print(f"{grocery[stuff]} {stuff}")
            break




lister()