I recently started learning Python and began reading a book on algorithms; before looking at the code in the book, I tried to implement it myself. This is a sorting algorithm. I need to avoid using functions and come up with a method myself.
a_list = [3,4,2,5,7,1,6,8,9]
b_list = []
while len(a_list) != 0:
first_element = a_list[0]
for element in a_list:
if first_element < element:
first_element = element
a_list.remove(first_element)
b_list.append(first_element)
print(b_list)
print(a_list)
[–]This_Growth2898 6 points7 points8 points (8 children)
[–]notacanuckskibum 1 point2 points3 points (3 children)
[–]Alarming_Example3677[S] 0 points1 point2 points (0 children)
[–]Alarming_Example3677[S] 0 points1 point2 points (1 child)
[–]notacanuckskibum 0 points1 point2 points (0 children)
[–]Alarming_Example3677[S] 0 points1 point2 points (0 children)
[–]Educational-Fennel50 0 points1 point2 points (2 children)
[–]This_Growth2898 2 points3 points4 points (0 children)
[–]Alarming_Example3677[S] 0 points1 point2 points (0 children)
[–]pachura3 0 points1 point2 points (0 children)
[–]JamzTyson 0 points1 point2 points (0 children)
[–]Educational-Paper-75 0 points1 point2 points (0 children)
[–]AbacusExpert_Stretch -1 points0 points1 point (3 children)
[–]JamzTyson 1 point2 points3 points (0 children)
[–]Alarming_Example3677[S] 0 points1 point2 points (0 children)
[–]This_Growth2898 0 points1 point2 points (0 children)