I need to get:
'W1NaCl U1NaCl V1NaCl'
from:
[['W1NaCl'], ['U1NaCl'], ['V1NaCl']]
How to get required output in pythonic
way
CodePudding user response:
items = [['W1NaCl'], ['U1NaCl'], ['V1NaCl']]
res = " ".join([item[0] for item in items])
Which yields: W1NaCl U1NaCl V1NaCl
CodePudding user response:
You can do:
[[i] for i in 'W1NaCl U1NaCl V1NaCl'.split()]
Split will chop it into words, and the list comprehension will make the inner-arrays