0

In a range(start, end) function in python, why the end value is excluded

print(0,6) # prints numbers from 0 to 5 and the end value 6 is exlcuded

I just want to know why the range function is designed in such a way. Is there any specific reason?

TheMisir
  • 4,083
  • 1
  • 27
  • 37

1 Answers1

0

If you just use an end value, you get that many numbers.

>>> range(6)
[0, 1, 2, 3, 4, 5]

>>> len(range(6))
6
Ben Soyka
  • 816
  • 10
  • 25