I am trying with an unknown list
def what_is_my_max(listunknown):
unknown_list = []
for things in lst:
sorted(unknown_list)
things.pop(max(unknown_list))
return unknown_list
Please help
I am trying with an unknown list
def what_is_my_max(listunknown):
unknown_list = []
for things in lst:
sorted(unknown_list)
things.pop(max(unknown_list))
return unknown_list
Please help
A few points.
lst
in your code isn’t defined.unknown_list
since your function seems to accept a list as an argument assigned to the parameter, listunknown
.max()
method.You could start by writing a list of numbers on a piece of paper. Then consider the steps that you would take to determine which number is the largest. Write those steps down. Better yet, how would you explain to a child how to find the largest number? Write those steps down. Then consider python code for each step.
If we’re to go by the title, calculating the maximum
then it would suggest NOT using the built-in, but writing our own algorithm. If we cannot do that, then how would we ever explain how max()
works? Best to work with the naive algorithms and master them before reaching for built-ins that teach us nothing.
So should I use max or create my own algorithm?
For the practice and the mental imaging, write an algorithm.