How to repeat each element in counter as many times as it count into a list with Python

1 Answer

0 votes
from collections import Counter

c = Counter(a=3, b=2, c=1, d=0)

lst = list(c.elements())

print(lst)


'''
run:
 
['a', 'a', 'a', 'b', 'b', 'c']

'''

 



answered Nov 5, 2018 by avibootz
...