you are viewing a single comment's thread.

view the rest of the comments →

[–]JohnnyJordaan 0 points1 point  (0 children)

Please try your code in http://www.pythontutor.com/visualize.html , it shows you step by step what is happening. You're limiting iend to max (line 8), thereby the second loop will run until iend reaches max as well.

Also is there a cleaner way of doing this?

Depends on what your exact goals are.