Skip to content

Commit a552159

Browse files
authored
Update genericRoutines.py
1 parent 03865c2 commit a552159

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

genericRoutines.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,16 @@ def countOccurancesInList(l):
6060
d[item] = 1
6161

6262
print(d)
63+
64+
65+
#OR
66+
67+
def countOccurancesInList(l):
68+
d = {}
69+
for item in l:
70+
d[item] = d.get(item, 0) + 1
71+
72+
print(d)
6373

6474
#####################################################################################################################
6575
"""Transpose a multidimensional list

0 commit comments

Comments
 (0)