Quick Lists Question (Count Occurences) - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Homework (https://python-forum.io/forum-9.html) +--- Thread: Quick Lists Question (Count Occurences) (/thread-948.html) Pages:
1
2
|
RE: Quick Lists Question (Count Occurences) - heiner55 - Nov-16-2016 If you can not use collections, write your own Counter: def MyCounter(lst): dic = {} for e in lst: if e in dic: dic[e] += 1 else: dic[e] = 1 return dic lst = [] print("Enter 9 numbers: ") for i in range(9): lst.append(int(input())) print(MyCounter(lst)) RE: Quick Lists Question (Count Occurences) - metulburr - Nov-16-2016 (Nov-16-2016, 05:10 PM)nilamo Wrote:(Nov-16-2016, 05:04 PM)metulburr Wrote: I thought you couldnt use collections?That's not OP. whoops lol RE: Quick Lists Question (Count Occurences) - heiner55 - Nov-17-2016 Thanks |