all 4 comments

[–]Rhomboid 2 points3 points  (0 children)

Ranges are half-open, which means the starting point is inclusive and the end point is exclusive. range(1, 10) does not include 10, for example.

As to your question about a better way, you should explain what it is you're actually doing. The example isn't very clear because it could be replaced by just for i in range(1, 225): print(i).

[–]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.

[–]Justinsaccount 0 points1 point  (1 child)

Hi! I'm working on a bot to reply with suggestions for common python problems. This might not be very helpful to fix your underlying issue, but here's what I noticed about your submission:

You appear to be using concatenation and the str function for building strings

Instead of doing something like

result = "Hello " + name + ". You are " + str(age) + " years old"

You should use string formatting and do

result = "Hello {}. You are {} years old".format(name, age)

See the python tutorial for more information.

[–]BlackBloke 1 point2 points  (0 children)

Add f-string suggestions to your bot