So I have these tuples in two lists in another tuple which look like
data_tuple = ([(1,2,3),(4,5,6)(7,8,9)],[(a,b,c),(d,e,f)(g,h,i)])
I want to build a set of coordinates using the corresponding indexed elements from each list, so that it looks like
final = [(2,b),(5,e),(8,h)]
Here’s what I got:
for a in data_tuple[0]:
x = a[1]
for b in data_tuple[1]:
y = b[1]
print(x,y)
For now I just wanna check if my iteration/indentation is right so I don’t need to put them in a list just yet. Right now the outcome for this particular code is
(2,b)
(2,e)
(2,h)
(5,b)
(5,e)
and so on until it reaches (8,h).
If I bring my print line to the left, under the second for loop, I get
(2,h)
(5,h)
(8,h)
How do I fix this? Sorry if I don’t make any sense =/. As you can tell I’m extremely new to Python so I’m not familiar with a lot of import modules. Any help please?
but often clarity is more important than brevity
I dont really understand your original question since it looks like its working as intended that implies your indentation and iteration is fine..
[edit] this is what you want i think
or