Selection sort

vani arul arulvani66 at gmail.com
Fri Dec 24 09:22:58 EST 2021


Hello,
I am trying write a code.Can some help me find the error in my code.
Thanks!


def selectionsort(arr):
   # le=len(arr)
    for b in range(0,len(arr)-1):
        pos=b
        for a in range(b+1,len(arr)-1):
            if arr[b]>arr[a+1]:
                arr[b],arr[a+1]=arr[a+1],arr[b]
    return arr

arr=[3,5,9,8,2,6]
print(selectionsort(arr))


More information about the Python-list mailing list