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

Python Python Collections (Retired) Lists Redux Combining Lists

List Range in Python: Static or Dynamic Value?

When Kenneth introduces the topic of Combining lists, he gives an example of:

Python
our_list(range(10))

However, he then adds the ints: 10, 11, and 12 to the end of the list successfully. That confuses me because I thought the range of the list would be 0-9 and not allow you to add extra values to the end of the list. So am I correct that the range is static and there's something else I don't know about in play that allows Kenneth to add 10, 11, and 12 to the list, or is the value of the range dynamic and we can just add or subtract from the list as needed?

1 Answer

Steven Parker
Steven Parker
229,644 Points

What he actually did was this:

our_list = list(range(10))

The "list" function converts the range (which you cannot add to) into a list that you can add to.