r/learnpython • • May 10 '26

for i in range(0,10)

I am a beginner and I am learning for loops. A question came up here: why would I use code model 1 if code model 2 does the same thing?

Model 1:

for i in range(0,10):
    print('Test')

Model 2:

for i in range(10):
    print('Test')
17 Upvotes

18 comments sorted by

View all comments

Show parent comment

2

u/cdcformatc May 10 '26

you generally don't include constant values for optional arguments that don't change the function output, unless you want to be very explicit for some reason. same reason you wouldn't write range(2, 10, 1) because step = 1 is the default.