a = [
[1, 2],
[1, 2]
]
print([x for x in [x for x in a]])
[[1, 2], [1, 2]]
But I want to see something like that:
[1, 2, 1, 2]
How I cad do this?
>Solution :
Try this.
a = [
[1, 2],
[1, 2]
]
lst = [q for i in a for q in i]
print(lst)
The above one is not always working it gives you an error if the list is something like this.
a = [[1, 2],[1, 2],2]
But this one always work.
a = [
[1, 2],
[1, 2]
]
lst = []
for i in a:
if type(i) == list:
lst.extend(i)
else:
lst.append(i)
print(lst)