我一直在寻找如何考虑“k”来解决以下问题。基本上,它应该从索引 k 开始,并在从 k 到列表末尾的范围内查找最小值。
def find_min_index(A, k):
"""
Finds the index of the smallest element in the list A from index k onwards
Parameters:
A (list)
k: index from which start search
Example use:
>>> find_min_index([1, 2, 5, -1], 0)
3
>>> find_min_index([1, 1, 1, 5, 9], 2)
2
"""
minpos = A.index(min(A))
return minpos
慕莱坞森
慕姐8265434
宝慕林4294392
BIG阳
随时随地看视频慕课网APP
相关分类