dict = {x: arr.count(x) for x in arr}
want to break it in more lines of code how to do it? or is there any other way to write it to understand the concept clearly?
dict = {x: arr.count(x) for x in arr}
want to break it in more lines of code how to do it? or is there any other way to write it to understand the concept clearly?
Use for loop
arr = [1, 2, 1, 3, 4, 5, 10]
dict = {}
for x in arr:
dict[x]=arr.count(x)
print(dict)