I have [1,2],[5],[2,7,9] and I want to make [[1,2],[5],[2,7,9]]. I tried some commands but they all return [1,2,5,2,7,9].
Can someone help?
Thanks
I have [1,2],[5],[2,7,9] and I want to make [[1,2],[5],[2,7,9]]. I tried some commands but they all return [1,2,5,2,7,9].
Can someone help?
Thanks
l1 = [1,2]
l2 = [5]
l3 = [2,7,9]
new_list = []
new_list = [l1] + [l2] + [l3]
print(new_list)
# or
new_list = []
new_list.append(l1)
new_list.append(l2)
new_list.append(l3)
print(new_list)
# or
new_list = []
new_list+=[l1]
new_list+=[l2]
new_list+=[l3]
print(new_list)
Output:
[[1, 2], [5], [2, 7, 9]]
[[1, 2], [5], [2, 7, 9]]
[[1, 2], [5], [2, 7, 9]]