truthiness

How Python treats any value as true or false in a condition: zero, empty collections, empty strings and None are false; nearly everything else is true.

In more detail

So if items: means if the list is not empty, and while line: stops at an empty string. The short list of false values is False, None, 0, 0.0, "", [], (), {} and set(). It is also why x == 1 or 2 is always true.

Related terms

Taught in

References

Certification courses