Understanding Python’s Truthy and Falsy Values


Learn which values are considered True and False in an if statement context. For example, empty sequences and collections are considered False.

Source Code

if []:
    print("This won't print.")
if [1, 2, 3]:
    print("A non-empty list is truthy.")
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments