why we are entering num_2+1 and num_1+1 in for loop code
num_2+1 and num_1+1
in for loop why we are using 1+1,2+1
1 answers ( 0 marked as helpful)
Hey Satthya,
Thank you for your question!
The reason we are adding one is because of how the range()
function works. Imagine that you want to print the numbers from 1 to 10, including 10. If I attempt to do that with range(1, 10)
, I will get the following output:
What I need to do to output 10 as well is to add 1 to 10 as follows:
Therefore, if we want to include the numbers num_1
or num_2
, we need to add one in the range()
function.
Hope this helps!
Kind regards,
365 Hristina