Rethunk
0
Q:

max in a list python

# any list
a = [1, 7, 3, 12, 5]

# index of minimum element
# if more than 1 minimum, 
# first index is returned
min_index = a.index(min(a))

# index of maximum element
max_index = a.index(max(a))
2
>>> L=[2,-7,3,3,6,2,5]
>>> max(L)
6
3
li=[0,70,7,89]
max(li)
#gives the max value 89
2
max(list)
0
print(max(2, 3)) # Returns 3 as 3 is the largest of the two values
print(max(2, 3, 23)) # Returns 23 as 23 is the largest of all the values

list1 = [1, 2, 4, 5, 54]
print(max(list1)) # Returns 54 as 54 is the largest value in the list
0
#!/usr/bin/python

list1, list2 = [123, 'xyz', 'zara', 'abc'], [456, 700, 200]
print "Max value element : ", max(list1)
print "Max value element : ", max(list2)
-1

New to Communities?

Join the community