Skip to content
Code ReadingWhere Is the Largest?
Break the Code

Where Is the Largest?

Write a list for which this function gives the wrong answer.
1def index_of_max(values):
2 best = 0
3 for i in range(1, len(values)):
4 if values[i] >= values[best]:
5 best = i
6 return best