Tuple Length in Python

Level 119 keystrokes

This uses len() to get the number of elements in a tuple.

Python code

# (1,2,3) is a tuple with 3 elements; the outer parentheses belong to len()
# 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.

  • (× 3
  • )× 3
  • ,× 2

More Python examples at level 1

← Python typing practice