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) Slices Deleting slices

what is the answer for this question?

what are the three parts of slice syntax?

3 Answers

We're actually not meant to just give away the answers here on the forums. That doesn't help anyone learn.

You should get used to searching for your answers, starting from the official documentation, but you'll often find yourself on sites like Stack Overflow.

Here's a page on the Python docs that should help you find the answer you're looking for:

https://docs.python.org/3/library/functions.html#slice

Robert Stefanic
Robert Stefanic
35,170 Points

The slice syntax is composed on a start value, a stop value, and the increment value.

my_list[start:stop:increment]

So as an example, say you wanted to print the odd numbers from a list of numbers, 1 - 10.

my_list = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

my_list[0:9:2] 
# [1, 3, 5, 7, 9]