+ 1
Use of range(n, n+1) in Python
Do we need to use the range(n, n + 1) only with factorials or can be used with other kind of purpose? Example of my code: https://code.sololearn.com/cwZyW1yDa67n/?ref=app Thank you in advance.
7 Answers
+ 4
Python `range` function includes the first argument given, but the function excludes the second argument given. So, taking for example `range(<from>, <to>)`, <from> is the beginning, whereas <to> minus 1 is the end.
range(1, 10) # 1 up to 9
Doing `range(<from>, <to> + 1)` means the range will begin with <from> and ends by <to> inclusively.
range(1, 10 + 1) # 1 up to 10
+ 3
It's why there is such a community
Maybe one day you help me out
Who knows right? đ
+ 2
Excelente, Ipang, now is more clear that range (n, n + 1) for me, very simple and powerful explanation, Thanks, gracias
+ 2
Ipang don't worry, I'll keep looking for your help đž
+ 2
That's right, absolutely, indeed!
+ 1
De nada Whally O đ