I have a list with n elements but i would like to convert it to a list which contains n list, and every list contains a single element.
a = ['1','2','3','4']
b = [['1'],['2'],['3'],['4']]
How can I make from a to b?
You can try list comprehension
b = [[i] for i in a]
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