
Keshava
asked

Expert
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 Getting started with Python course.
Our Experts
Sudip BhandariHead of Growth/Marketing
Apekchhya ShresthaSenior Product Manager
Kelish RaiTechnical Content Writer
Abhilekh GautamSystem Engineer
Palistha SinghTechnical Content Writer
Sarthak BaralSenior Content Editor
Saujanya Poudel
Abhay Jajodia
Nisha SharmaTechnical Content Writer
Udayan ShakyaTechnical Content Writer