I have a python array that looks like this: [1, 2, 3, 4, 5]
I want it to look like this: [[1], [2], [3], [4], [5]]
How do I go about doing this?
Thanks!
I have a python array that looks like this: [1, 2, 3, 4, 5]
I want it to look like this: [[1], [2], [3], [4], [5]]
How do I go about doing this?
Thanks!
I assume you are talking about lists. This should work:
l = [1, 2, 3, 4, 5]
out = [[i] for i in l]
You can also do it like this using append method of list
list_a = [1,2,3,4,5]
new_list = []
for i in list_a:
new_list.append([i])