def count_numbers arr counts for in arr if in counts counts else count

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
def count_numbers(arr):
counts = {}
for i in arr:
if i in counts:
counts[i] += 1
else:
counts[i] = 1
return counts
arr1 = [6, 5, 3, 5, 9, 5, 4, 4, 3, 2, 7, 3, 6, 7, 2]
arr2 = [7, 7, 4, 2, 8, 9, 2, 6, 4, 8, 8, 5, 7, 3, 2]
print(count_numbers(arr1))
print(count_numbers(arr2))