Set Length in Python

Level 119 keystrokes

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

Python code

# {1,2,3} is a set: an unordered collection where each value appears only once
# It holds 3 distinct values, so len() returns 3
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