Reputation: 175
If I have this list,
list01 = ['GAGGT','TCCGT','ABECF']
I want to make each element in the list to split, but still remain in the same box of list. Like this:
listalt = [['G','A','G','G','T'],['T','C','C','G','T'],['A','B','E','C','F']]
Upvotes: 0
Views: 72
Reputation: 12689
You can use this :
final_list=[]
for item in list01:
final_list.append(list(item))
print(final_list)
which is same as :
print([list(item) for item in list01])
Upvotes: 0
Reputation: 61063
listalt = [list(i) for i in list01]
This is a list comprehension, and uses the fact that list
can take an iterable (like a string) and turn it into a list
Upvotes: 1