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 trialf4u57
6,743 PointsSlicing With A Step question
So here is my question: example
numbers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
numbers[::2] will give the even numbers of the list. So is the reason this works because the start and end are not given thus it will jump 2 spaces from 0 indexes?
I know this is kinda a silly logic question but I want to make sure.
1 Answer
Steven Parker
231,172 PointsThe step value can be used with or without start and stop values. If you leave them out, the default start is the first item, and the default stop is right after the last item.