def main():
a = [2,1,5,234,3,44,7,6,4,5,9,11,12,14,13]
max = 0
for number in a:
if number > max:
max = number
print max
if __name
You can use enumerate
to also give you an index while iterating through a list:
>>> a = [2, 1, 5, 234, 3, 44, 7, 6, 4, 5, 9, 11, 12, 14, 13]
>>> maxIndex, maxNumber = 0, 0
>>> for index, number in enumerate(a):
if number > maxNumber:
maxIndex = index
maxNumber = number
>>> maxIndex, maxNumber
(3, 234)