How do I make a program in python to select the highest number from a list | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How do I make a program in python to select the highest number from a list

I am working on a program and I have a problem I am not good at lists if you know how to do it in python please respond to this

31st Mar 2020, 8:12 PM
AndreiJK
AndreiJK - avatar
3 Answers
+ 3
Use max() function arr = [3, 9, 1] print(max(arr)) Output: 9
31st Mar 2020, 8:24 PM
Simone Crema 🇮🇹
Simone Crema 🇮🇹 - avatar
+ 5
#you could also use sort / sorted arr = [3, 9, 1] print(sorted(arr)[-1]) #Output: 9
31st Mar 2020, 8:42 PM
Lothar
Lothar - avatar
+ 2
If there were not ways to do this with standard functions you can solve it with loops and it can be a good exercise. l=[56,32,85,74,110,2,99,115] t=0 for n in l: if t<n: t=n print(t)
31st Mar 2020, 11:05 PM
GeraltdeRivia