List Length in Python

Level 121 keystrokes

This prints the number of elements in a list. The len() function returns the count of items in a collection.

Python code

# [1, 2, 3] is a list holding three integers
# len() returns the number of elements, so 3 is printed
1print(len([1, 2, 3]))

Output

3
Practice typing this code

Practice typing this code. Results are not recorded in the rankings.

Symbols in this code

The symbols you type in this Python code and how often they appear.

  • ,× 2
  • (× 2
  • )× 2
  • [× 1
  • ]× 1

More Python examples at level 1

← Python typing practice