Keshava Harshith Manikyala
PRO
2 months ago
Keshavacountry asked

Example if I create a range(1,7) at list(). then o/p is "[1,2,3,4,5,6]" why here '7' is ignored is it using the indexing count.

Kelish Rai
Expert
2 months ago
Kelish Rai answered

When you do range(1, 7), it gives you numbers starting from 1 up to but not including 7. So it stops at 6.

It’s not about indexing exactly — that’s just how range() works in Python. The second number is treated as the "stop point", and it’s excluded from the result.

Let me know if you need more explanation on this. I'm happy to help.

Python
This question was asked as part of the Learn Python Basics course.