Sum Program For Python

Hi,

I am currently new to programming. I’m trying to understand the statement at line 3 of the following Sum Program:

1 def sumOfN(n):
2 theSum = 0
3 for i in range(1,n+1):
4 theSum = theSum + i
5
6 return theSum
7
8 print(sumOfN(2))

How does the arguments in the bracket at line 3 (1, n+1) result in i being 1 when it is first executed?

Hi,
The range() function returns a sequence of numbers from 1 to n + 1 (not include).

Link