so im trying to implement selection sort in python.. and im appending the result of each iteration to a list to print at the end.. my code sorts the list of numbers properly but
I don't see the actual sort that you're doing, but in general:
Lists are mutable. Any change you make to it affects all links to that list. To make a copy of it and break its connection to other references, you need to return alist[:]
def s_sort(numbers):
alist=[]
#do actual sorting here and swap numbers/index if neccessary
alist.append(numbers)
return alist[:] # this makes it a copy!
def main():
numbers=[5,7,3]
print(s_sort(numbers))
main()