Sobes.tech
Junior — Middle

What does an empty dictionary mean in Python logic — true or false?

sobes.tech AI

Answer from AI

In Python, an empty dictionary {} evaluates to False in a boolean context. Any non-empty dictionary is considered True.

Example:

if {}:
    print("True")
else:
    print("False")  # Will print "False"

if {"key": "value"}:
    print("True")  # Will print "True"
else:
    print("False")