How to get a max no . in a list?? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How to get a max no . in a list??

User input a long list and result the max no. In the list and also want place of that no. Anyone plz explain

11th Sep 2016, 12:34 PM
Sunil Kumar Mahich
Sunil Kumar Mahich - avatar
4 Answers
+ 3
max (name of the list) to 'get the Max no. The position you 'get it with index[Max no].
11th Sep 2016, 1:05 PM
Carlos Sacanell
Carlos Sacanell - avatar
+ 2
It works for range 0-9 but it doesnt recognise the numbers bigger than 9... thats for the definition of the Split i think
11th Sep 2016, 1:16 PM
Carlos Sacanell
Carlos Sacanell - avatar
+ 2
the problem is the Input. when you get an Input is string type and you can convert it to float or integer but if you give more than one inputs automatly Python creates a list of strings and you can convert the list in a float or integer type. i think thats the reason for not to run for numbers bigger than 9...
11th Sep 2016, 2:16 PM
Carlos Sacanell
Carlos Sacanell - avatar
+ 1
Here's the full code: a=input() b=a.split(" ") c=max(b) d=b.index(max(b)) print("The highest number is: ",c) print("It's place in the list is: ",d+1)
11th Sep 2016, 1:10 PM
Alexandre Balea
Alexandre Balea - avatar