x=range(1,4)
y=range(1,4)
[(xi,yi) for xi in x for yi in y if xi is yi]
#output
# [(1, 1), (2, 2), (3, 3)]
[(xi,yi) for xi in x if xi is yi for yi in y ]
#output, I am confused about this one
#[(3, 1), (3, 2), (3, 3)]
Can any one explain why the second loop results like this?
I am quite confused about how multiple in-line loops work in Python.
Also, any tutorial on python in-line loops is favored
islike that.ischecks object equality, not value equality.isto compare numbers. Use==.