Solution 1:
list1=[1,2,1,3] count={} for item in list1 : print item if item not in count: #check if item is in list count[item]=0 #if no then set item key value print count[item] count[item]+=1 #yes increment print count[item] print count
No comments:
Post a Comment