I'm trying to find the greatest integer in a list with Python but the thing is I don't want the greatest value, I would like to find the integer with the greatest value on array. Is there any way to do this?
The array I am trying to find the integer with greatest value was like that;
int1, int2, int3, int4, int5 = 5, 10, 20, 15, 5
line = [ int1, int2, int3, int4, int5]
And I would like get the integer with a greatest value (in that case int3) but instead they are not fixed in the code I wrote.
If you are looking for the index value of the largest number in the list you can use the following.
>>> ls = [5,10,20,15,5]
>>> ls.index(max(ls))
2
>>> ls[2]
20
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.