Sobes.tech
Middle

What will print(bool([])) print(bool([0]))

sobes.tech AI

Answer from AI

In Python, the bool() function returns the boolean value of an object by evaluating its truthiness.

  • bool([]) — an empty list is considered false, so the result will be False.
  • bool([0]) — a list with one element (even if it is 0) is considered true, so the result will be True.

Example output:

print(bool([]))   # False
print(bool([0]))  # True