List length

Lists and collections / Lists

numbers = [1, 2, 3]
length = len(numbers)
# length is 3

# Count by condition
count_odd = sum(1 for n in numbers if n % 2 == 1)
# count_odd is 2

# Empty list is falsy: no len() == 0
is_empty = not numbers
# is_empty is False

print(f"{length = }")
print(f"{count_odd = }")
print(f"{is_empty = }")