0
Please Debug Code. And explain me solution of the problem
Code for Sorting a list without using sort() function https://code.sololearn.com/cjnMeNx3Glrj/?ref=app https://code.sololearn.com/cjnMeNx3Glrj/?ref=app
2 Respostas
+ 4
Just run your code, it will tell the mistake you made:
list index j+1 is out of range
+ 4
To elaborate on Angelo 's answer and the error message:
In both the inner loop, you're looping with variable `j` through range - range(0, 5) (as len(list1) is 5). Now, in the inner loop, try to imagine what happens on line 6 when j = 4
`if list1[j] > list1[j+1]`
= `if list1[4] > list1[5]:`
Here, list1[5] does not exist