List Maximum in Python

Level 244 keystrokes

This finds and prints the maximum value in the list, which is 96. The max() function returns the largest element.

Python code

# Create a list of score values
1scores = [85, 92, 78, 96]
# max() is a built-in function that finds the largest value
# It compares all elements and returns 96 (the highest score)
2print(max(scores))

Output

96
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
  • (× 2
  • )× 2
  • [× 1
  • ]× 1
  • =× 1

More Python examples at level 2

← Python typing practice