0
How do I find the largest number in a list without using max()?
Imagine you have a list like this: nums = [4, 9, 2, 11, 7] If I donât want to use the built-in max() function, how can I figure out the biggest number in that list just using a loop?
2 Réponses
+ 1
Your attempt!??
p.s. iterate through loop, and compare the number to a previously found maximum number.
+ 1
A short pythonic way might be to use sorted then grab the last number.
print(sorted(nums)[-1])