I have managed to make an algorithm that sorts through all of the numbers however, since it technically iterates over each element, it’s being counted as unnecessary swapping so I can’t get past test case #6.
Your code so far
def selection_sort(num_list):
for i in range(len(num_list)):
for j in range(len(num_list) - 1):
if num_list[j] > num_list[j + 1]:
temp = num_list[j]
num_list[j] = num_list[j + 1]
num_list[j + 1] = temp
return num_list
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:150.0) Gecko/20100101 Firefox/150.0
Challenge Information:
Implement the Selection Sort Algorithm - Implement the Selection Sort Algorithm