In python
a = [['z', 'G', 'j', 'E', 'U'], ['%', '#', '(', '!', ')'], ['6', '4', '8', '1', '3']]
I want to print above nested list into character which are side by side example output:
zGjEU%#(!)64813
How to do that?
In python
a = [['z', 'G', 'j', 'E', 'U'], ['%', '#', '(', '!', ')'], ['6', '4', '8', '1', '3']]
I want to print above nested list into character which are side by side example output:
zGjEU%#(!)64813
How to do that?
Consider a nested comprehension along with str.join
:
>>> a = [['z', 'G', 'j', 'E', 'U'], ['%', '#', '(', '!', ')'], ['6', '4', '8', '1', '3']]
>>> print(''.join(c for chars in a for c in chars))
zGjEU%#(!)64813
a = [['z', 'G', 'j', 'E', 'U'], ['%', '#', '(', '!', ')'], ['6', '4', '8', '1', '3']]
result = ""
for item in a:
for char in item:
result += char
result:
'zGjEU%#(!)64813'