I am having a hard time putting multiple list into one because they are all inside one variable.
here is an exemple:
What I have
a = ['1'], ['3'], ['3']
What I want
a = ['1', '3', '3']
How can I resolve that using Python 3.x
EDIT
here is the code I'm working on.
from itertools import chain
def compteur_voyelle(str):
list_string = "aeoui"
oldstr = str.lower()
text = oldstr.replace(" ", "")
print(text)
for l in list_string:
total = text.count(l).__str__()
answer = list(chain(*total))
print(answer)
compteur_voyelle("Saitama is the One Punch Man.")
Console Result :
saitamaistheonepunchman.
['4']
['2']
['1']
['1']
['2']
You can use itertools.chain
.
In [35]: from itertools import chain
In [36]: a = ['1'], ['3'], ['3']
In [37]: list(chain(*a))
Out[37]: ['1', '3', '3']
Or
In [39]: list(chain.from_iterable(a))
Out[39]: ['1', '3', '3']
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With