I wrote a code for insertion sort that now works great (yes, it's homework). But, before that code I wrote a different one that doesn't work and I just don't know why. Please help me understand...
This is my older code:
def insertion_sort(lst):
if len(lst)==1:
lst=lst
else:
for i in lst[1:]:
if i==min(lst[0:lst.index(i)]):
lst.remove(i)
lst.insert(0, i)
return lst
I do not need a new insertion sort, I already wrote one. I just need the explanation for why this specific code didn't work.
lst=lstsupposed to do?passstatement?