How to create a list from number of letters in the counter in Python

1 Answer

0 votes
from collections import Counter

c = Counter(a = 5, b = 3, c = 2, d = -3, e = 0)

lst = list(c.elements())

print(lst)



'''
run:

['a', 'a', 'a', 'a', 'a', 'b', 'b', 'b', 'c', 'c']
 
'''

 



answered Jul 26, 2019 by avibootz

Related questions

...