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?

29th Jul 2025, 10:47 PM
SAIFULLAHI KHAMISU
SAIFULLAHI KHAMISU - avatar
2 Réponses
+ 1
Your attempt!?? p.s. iterate through loop, and compare the number to a previously found maximum number.
29th Jul 2025, 11:13 PM
Aleksei Radchenkov
Aleksei Radchenkov - avatar
+ 1
A short pythonic way might be to use sorted then grab the last number. print(sorted(nums)[-1])
30th Jul 2025, 12:07 AM
BroFar
BroFar - avatar