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.

2
  • \$\begingroup\$ Can you explain why p%10<k>q doesn't throw a NameError if p%10 >= k? \$\endgroup\$ Commented Dec 11, 2018 at 19:36
  • 1
    \$\begingroup\$ @BlackOwlKai chained comparisons are lazily evaluated in Python. This means as soon as a first false comparison appears, the chain will no longer be evaluated. In this case p%10<k>q does the same as p%10<k and k>q. \$\endgroup\$ Commented Dec 11, 2018 at 19:45