Implement the Selection Sort Algorithm test#6

Thnxs for the oportunity to learn, is fantastic…
i do the exercise perfect, i understand the logic of the algorithm, i implemented a function working good, passes al tests, but not the 6. i tried many ways. i looked into webs woth explanation, i asked IA, i got it correct, but cant pass de test, and i cannot get the exercise finished. i m here, for more of 2 houres behind this exercise.

def selection_sort(array: list):
    largo = len(array)
    for i in range(largo):
        min_idx = i      
        
        for j in range(i + 1, largo):
            if array[j] < array[min_idx]:
                min_idx = j
        
        array[i], array[min_idx] = array[min_idx], array[i]
    return array

cant see the problem.

at least i found the solution, if some one is here for the same a can bring the hint.

here is the solution:

What if the current number is also the lowest number? Should they swap?

1 Like

Sounds familiar

Always good to search the forum here first before web or gpt. Many people get stuck on the same points of each problem and the same problems have been explained many times here.