Test 0 and false since false is 0

Skip Montanaro skip.montanaro at gmail.com
Thu Jul 6 22:57:20 EDT 2017


I was trying to solve a problem and cannot determine how to filter 0's but
not false.


I'm typing on my phone so can't paste a session, so I will attempt to apply
the Socratic method, and ask: Do you understand why your attempts have
failed so far? In what way are False and 0 the same? In what respects do
they differ? Hint: think class relationships.

Not trying to be difficult. Just thought I'd change things up a bit. If you
come away with a bit deeper appreciation of Python's type system, you'll be
a bit better off down the road.

Skip



More information about the Python-list mailing list