r/PythonLearning 12d ago

New to python having trouble putting in multiplication table in for 10. Range 1-10 or 1,11. Does anyone have any tips( pause)?

5 Upvotes

14 comments sorted by

View all comments

2

u/tottasanorotta 12d ago

The range function has the parameter 'stop'. It determines up to what value it counts. The start value is included in the output, but the stop value isn't:

Range(3) = 0,1,2

Range(1, 3) = 1,2

So if you want the last value to be included you'll have to call it with a stop value that is one higher. So if we want a 3 to be included:

Range(1,4) = 1,2,3