Python Mastery – From Basics to Brilliance / Python Fundamentals

Truthy and Falsy Values

✅ What are Truthy and Falsy Values?

In Python, every value can be evaluated as either True or False when used in a condition.

  • Truthy → Values that behave like True

  • Falsy → Values that behave like False


🟢 Truthy Values

Most values in Python are Truthy.

if "Hello":
    print("This will execute")

Other examples:

True
10
-5
"Python"
[1, 2, 3]
{"name": "Tisha"}

🔴 Falsy Values

The following are commonly Falsy:

False
None
0
0.0
""
[]
()
{}
set()

Example:

name = ""
if name:
    print("Name exists")
else:
    print("Name is empty") # This block will be executed

🔍 Checking Truthy/Falsy with bool()

The bool() function converts a value into True or False.

print(bool(10))       # True
print(bool(0))        # False

print(bool("Hello"))  # True
print(bool(""))       # False

print(bool([1, 2]))   # True
print(bool([]))       # False

💡 Common Practical Use

Instead of writing:

name = ""

if name != "":
    print("Name entered")

You can simply write:

if name:
    print("Name entered")

This works because an empty string "" is Falsy.