Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

3
  • I’m not sure I understand your answer — if element in list-like object and for element in list-like object are two fundamentally different operations in Python. The second one performs iteration, not a membership test. The first one performs the membership test (see my answer) but the if isn’t part of the syntax. Commented Jul 26, 2016 at 20:46
  • I know. I just wanted to demonstrate other uses of the 'in' keyword. Commented Jul 26, 2016 at 20:52
  • Good use of if. Plus one. Commented Aug 1, 2016 at 17:43