list1 = ['a', 'a', 'B', 'B', 'c']
list2 = []
dict1 = {}
for tem in list1:
if tem not in list2:
dict1[tem] = list1.count(tem)
list2.append(tem)
print(dict1)
Sign in to make a reply
微尘初心
list1 = ['a', 'a', 'B', 'B', 'c']
list2 = []
dict1 = {}
for tem in list1:
if tem not in list2:
dict1[tem] = list1.count(tem)
list2.append(tem)
print(dict1)