Code correction
Hi,
In this lecture, while testing te insertion_sort function, the bubble_sort function was actually used. I'm not saying the code does not work, but it would be good to correct that part.
1 answers ( 0 marked as helpful)
Super learner
This user is a Super Learner. To become a Super Learner, you need to reach Level 8.
def insertion_sort(my_list):
n = len(my_list)
for i in range(1,n):
value = my_list[i]
j = i
while j > 0 and my_list[j-1] > value:
my_list[j] = my_list[j-1]
j -= 1
my_list[j] = value
return my_list
test_2 = [70,24,87,45,6,3,2,8,5]
print(insertion_sort(test_2))
It works, anyway: a correction would be fine.