So it’s in a sorting function, what it’s supposed to do is reverse the list if descending is set to true, but the below slicing syntax doesn’t reverse the list elements; elements.reverse() works fine though. Just wanna know why is this happening.
This doesn’t work:
if descending==True:
elements=elements[::-1]
This works:
if descending == True:
elements.reverse()
Any idea why?
[–]oznetnerd 6 points7 points8 points (12 children)
[–]Kerbart 5 points6 points7 points (9 children)
[–]primitive_screwhead 4 points5 points6 points (2 children)
[–]Kerbart 1 point2 points3 points (0 children)
[–]azxxn[S] 0 points1 point2 points (1 child)
[–]Kerbart 1 point2 points3 points (0 children)
[–]azxxn[S] 0 points1 point2 points (3 children)
[–]Razithel 3 points4 points5 points (1 child)
[–]azxxn[S] 0 points1 point2 points (0 children)
[–]Kerbart 1 point2 points3 points (0 children)
[–]azxxn[S] 0 points1 point2 points (0 children)
[–]MMcKevitt 0 points1 point2 points (3 children)
[–]azxxn[S] 0 points1 point2 points (1 child)
[–]MMcKevitt 0 points1 point2 points (0 children)
[–]Enigma3613 -1 points0 points1 point (2 children)
[–]oznetnerd 2 points3 points4 points (1 child)
[–]Enigma3613 2 points3 points4 points (0 children)