def selection_sort_with_exchange (lst):
i=0
while i<len(lst)-1 :
k=i
min1=lst[i]
j=i+1
while j<len(lst):
if lst[j]<min1 :
min1=lst[j]
k=j
j+=1
temp=lst[k]
lst[k]=lst[i]
lst[i]=temp
i+=1
return lst
while True :
lst=input("enter a list :")
print selection_sort_with_exchange(lst)
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.