"Steven D'Aprano" <st...@pearwood.info> wrote
List comps can include *any* comparison:
[x+1 for x in data if (3*x+2)**2 > 100*x or x < -5]
Sure, but the wording suggested (maybe wrongly) that the OP
was a real beginner and so the concept of an expression
was likely to be foreign. Sticking with equalty or inequality
seemed likely to be the most familiar test to him/her.
Trying to explain the differnce between is and == seemed
like it would be a diversion from the primary objective,
namely how to filter a list comp.
However I guess this discussion has covered that topic too
now, so once again we have managed to kill several
sparrows with one round of buckshot... :-)
--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor