0d: 00h: 00m: 00s

🎁 Get 3 extra months of learning — completely FREE

That's 90 extra days to master new skills, build more projects, and land your dream job.

Become a PRO
Background Image

🎁 Get 3 extra months of learning completely FREE

Become a PRO
Keshava Harshith Manikyala
last year
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
last year
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.