Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.


Ranges are inclusive of the stop number. what does it mean

The answer was false but i don't understand why

Brian Mackenzie
Brian Mackenzie
6,059 Points

The answer was false because ranges in python are exclusive of the stop number. What this means is that when you write a range, for example, from 1-10, the stop number, or the last number, will not be included.

If you were to write some code like this:

      for i in range(1, 10):

it would only print out the numbers 1-9, as the stop number, 10, is excluded

Thanks, inclusive and exclusive. this terms

1 Answer

Steven Parker
Steven Parker
221,451 Points

The term "inclusive" means that the number will be part of the list. So if it was "inclusive", the list created by the range would have the last number in it.

But that's not how Python works. The list created by the range has numbers up to the last number, but the last number is not included in the list. So the answer is "False".