python - iterating over a subset of a list of tuples
Lets say I have a list of tuples as follows
l = [(4,1), (5,1), (3,2), (7,1), (6,0)]
I would like to iterate over the items where the 2nd element in the tuple
is 1?
I can do it using an if condition in the loop, but I was hoping there will
a be amore pythonic way of doing it?
Thanks
No comments:
Post a Comment