Editor

Find Maximum

#13 · Lists · Beginner · 45 XP · about 5 min

Write a function called find_max(numbers) that returns the largest number in a list.

Challenge: Try to solve this without using Python's built-in max() function!

Example

find_max([1, 5, 3, 9, 2])   # Returns 9
find_max([-1, -5, -3])      # Returns -1
find_max([42])              # Returns 42

Requirements

  • Return the maximum value
  • Handle negative numbers
  • You can assume the list is not empty

Fastest solvers

Leaderboard

First solves only, ranked by stars and then time.