I am currently being tasked with writing the bubble sort algorithm in python and one of the solutions I have come across contains this piece of code.
for passnum in range(len(alist)-1,0,-1):
for i in range(passnum):
if alist[i]>alist[i+1]:
temp = alist[i]
alist[i] = alist[i+1]
alist[i+1] = temp
In line 1 the range is specified with -1,0,-1 and I don't know why or what this does and was wondering if anyone could help out? Thanks.