Skip to content

Commit 8a4a1fd

Browse files
authored
Update genericRoutines.py
1 parent bd4e030 commit 8a4a1fd

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

genericRoutines.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,18 @@ def fibonacci_by_generator(num):
2222
"""print the number and its count in a list in order of their appearances
2323
example : [ 1,2,3,3,2,3,4,2,1] => 1:2,2:3,3:3,4:1
2424
"""
25-
def countOccurancesInList(inp_list):
25+
def countOccurancesInList(inp_list=None):
2626
s=set()
27+
res = []
2728
for x in inp_list:
29+
#print(x)
30+
print(f"current value is {x}")
2831
if x in s:
2932
pass
3033
else:
31-
print("{}:{}".format(x,inp_list.count(x)), end=",")
32-
s.add(x)
34+
res.append("{}:{}".format(x,inp_list.count(x)))
35+
s.add(x)
36+
return ','.join(res)
3337

3438
"""test the function
3539
countOccurancesInList([1,2,3,4,3,2,3,5,6,2,3,5,2,4,6,32,5,1,43,32,2,3,4,21,1,2,4,45,32,1,3,0])

0 commit comments

Comments
 (0)