I face a strange problem where set comprehension won't work as intended.
b=[[2,9,10],[3,7,15],[5,12,12],[15,20,10],[19,24,8]]
print({(R, 0, 0) for _, R, _ in b})
We have output
{(12, 0, 0), (9, 0, 0), (7, 0, 0), (20, 0, 0), (24, 0, 0)}
Not the desired answer
{(9, 0, 0), (7, 0, 0), (12, 0, 0), (20, 0, 0), (24, 0, 0)}
What went wrong? For list comprehension, it works fine.
b=[[2,9,10],[3,7,15],[5,12,12],[15,20,10],[19,24,8]]
print([(R, 0, 0) for _, R, _ in b])
We have output
[(9, 0, 0), (7, 0, 0), (12, 0, 0), (20, 0, 0), (24, 0, 0)]