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 Slicing With A Step

@3:56 in the video Kenneth gets a descending list...I do not

# when Kenneth does this
# he gets a descending list from 7 to 2
# I get the number 6
my_list = list(range(20))
x = my_list[7-1]
print(x)

1 Answer

Something is wrong with the video display or rendering I think. When you enter my_list[7-1] Python takes the math operand - and does 7 - 1. This means that what you are really doing is my_list[6] which will return 6.

Yeah, something might have went wrong with the video editing.

It probably should be showing

>>> my_list[7:1:-1]
[7, 6, 5, 4, 3, 2]

Yeah, as soon as I saw that, I had to attempt as well. Like jacinator , I received 6 as well.