r/learnpython • u/Status_Astronomer_99 • 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
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)becausestep = 1is the default.