|
A = input ("Enter the length of the list :")
# Too ask the user length of the list
L = []
# Take a emty list
For g in range ():
# For append the values from user
B = input ("Enter the element :")
# To ask the user to give list values
L. append (B)
# To append a values in a empty list l
Print "The given eliments list is", l
For I in range (len (l )):
# To repeat the loop take length of l
Index = I
# To store the values I in string index
Num = l [I]
# To take first value in list and store in num
For j in range (I + 1, len (l )):
# To find out the small value in a list read all values
If num> l [j]:
# To compare two values which store in num and list
Index = j
# To store the small value of the loop j in index
Num = l [j]
# To store small charecter are value in num
Tem = l [I]
# To swap the list take the temparary list stor list vlaues
L [I] = l [index]
# To take first value as another
L [index] = tem
Print "After the swping the list by selection sort is", l
|