✅ Explanation
In Python, any non-zero number (whether positive or negative) is considered truthy, meaning it evaluates to True in a conditional (if) statement.
So let's break it down:
a = -1 → a is assigned the value -1
if a: → Since -1 is not zero, it's treated as True
-
Therefore, the code inside the if block runs:
Output:
๐ Summary of Truthy & Falsy in Python:
| Value | Boolean Meaning |
|---|---|
| 0, 0.0 | False |
| None | False |
| "" (empty) | False |
| [], {}, set() | False |
400 Days Python Coding Challenges with Explanation | True |


0 Comments:
Post a Comment