Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial


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
228,978 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".