Editor settings

General settings

Save settings

Learn to program with Python

Get the length of a list #

You can get the length of a list using the len() function the same way you can get the length of a string.

For example:

numbers = [1, 2, 3, 4, 5]
length = len(numbers)
print(length) # Output: 5

Exercise #

Get the length of the variable names with the function len() and assign the length to another variable names_length

Tests #

  • Variable names_length should be 5
  • Must use function len()
Output will be displayed here