I have two lists J1 and A1. I have another list J2 with some elements from J1. I want to print corresponding values from A1 using A2. I present the current and expected output.
J1 = [1, 7, 9, 11]
A1 = [2.1,6.9,7.3,5.4]
J2 = [1, 9]
J2,A2=map(list, zip(*((a, b) for a, b in zip(J2,A1))))
print(A2)
The current output is
[2.1, 6.9]
The expected output is
[2.1, 7.3]
>Solution :
Another variation, closer to the original:
A2 = [a for a,j in zip(A1,J1) if j in J2]