python - What does the outer for loop do in my program? -


can please tell me functionality of outer for loop in program below:

mylist = [4,67,3,7,65,3,56,]  maxlengthlist = 7  print ('the number buble sort is:', mylist)  in range(len(mylist)-1,0,-1):     j in range(i):         if mylist[j]>mylist[j+1]:             temp = mylist[j]             mylist[j] = mylist[j+1]             mylist[j+1] = temp   print('after buble sort number are:',mylist) 

the loop step backward (-1) starting @ 6 (len(mylist)-1) , stopping @ 1, last value before stop (0). see range documentation range(start, stop, step)

>>> range(len(mylist)-1, 0, -1) [6, 5, 4, 3, 2, 1] 

Comments

Popular posts from this blog

Load Balancing in Bluemix using custom domain and DNS SRV records -

oracle - pls-00402 alias required in select list of cursor to avoid duplicate column names -

python - Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>] error -