Could I utilize max() to solve this?

I used this (very short) solution:

def max_num(nums):
return(max(nums))

worked right away :slight_smile:

The idea is to write a program to replace the max method, not use it directly. What would be the point of having our own function if we can just write,

max_num = max(nums)

?

Bottom line, don’t use built-ins when writing our own functions from scratch. What you have above teaches us nothing.

4 Likes

what about

def max_num(nums):
  return sorted(nums)[-1]

:slight_smile:

1 Like

Being a unit on loops and looping algorithms, one would hope we use some sort of iteration to determine the maximum value in the sequence. The only loop in that solution is the internal one of the sorted function, and would not count in this case.

On the plus side, at least it does not alter the order of the original list.

1 Like