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 (2016, retired 2019) Slices Slicing With A Step

Confused at 2:11?

I understand what the slicing of the code does to the list. But since he sliced the list first to. Won't that first slice create a new list which is now newly stored under the variable numbers. Instead when he slices the second time it uses the original list which was created. Why is this. Doesn't slicing create new modified lists?

1 Answer

Steven Parker
Steven Parker
231,269 Points

The slice does not modify the item it is used on. To retain the result of the slice, it would have to be saved, perhaps by assigning to another variable.

In the video, the result of the slice is being shown but not saved anywhere.

Ok thank you