# Finds the index of the minimum value of a list. # @param array list the array to search # @param start_index int the index to start at # @returns int the index of the minimum value or # the start_index if it is the smallest def findMinIndex(array, start_index): min_value = array[start_index] min_index = start_index for index in xrange(start_index, len(array)): if array[index] < min_value: min_value = array[index] min_index = index return min_index array = [18, 6, 66, 44, 9, 22, 14, 1, 5] print findMinIndex(array, 2)
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question