In Python, not everything is just True or False 🤯
Some values behave like True… even when they’re not.
1️⃣ Falsy Values ❌
These are treated as False:
print(bool(0))
print(bool(""))
print(bool([]))
Output: False False False
👉 Empty or zero-like values → False
2️⃣ Truthy Values ✅
Everything else is considered True:
print(bool(1))
print(bool("Hello"))
print(bool([1, 2]))
Output: True True True
👉 Non-empty values → True
3️⃣ Why This Matters ⚡️
name = ""
if name:
print("Has value")
else:
print("Empty")
Output: Empty
👉 No need to write
if name != "" 4️⃣ Common Mistake 🚫
if list == []: # ❌
👉 Better way:
if not list: # ✅
💡 Key Idea
Python doesn’t just check True/False
It checks if something is empty or not 🧠