I have a list of tuples, with each tuple containing a tuple pair, coordinates.
list1 = [((11, 11), (12, 12)), ((21, 21), (22, 22)), ((31,31), (32,32))] # list of tuple pairs
Using list comprehension I am trying to generate a list without them being paired but still in the same order. I was able to get the result be looping and using .append()
but I was trying to avoid this.
new_list = []
for i in list1:
for x in i:
new_list.append(x)
print(new_list)
output:
[(11, 11), (12, 12), (21, 21), (22, 22), (31, 31), (32, 32)]
this works and gives me the result I am looking for:
But when I try list comprehension I get the last tuple pair repeated!
new_list = [x for x in i for i in list1]
print(new_list)
output:
[(31, 31), (31, 31), (31, 31), (32, 32), (32, 32), (32, 32)]
I am sure it is a small thing I am doing wrong so would appreciate the help!!