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 Back and Forth

Tony Ahn
Tony Ahn
24,417 Points

Preview indicates that I should be correct, but can't pass

favorite_things = ['raindrops on roses', 'whiskers on kittens', 'bright copper kettles', 'warm woolen mittens', 'bright paper packages tied up with string', 'cream colored ponies', 'crisp apple strudels']

With this list, I'm supposed to make a slice with the last two variables... which I did.

slice2 = favorite_things[::-1][0:2]

But I can't seem to be able to pass :( any help?

slices.py
favorite_things = ['raindrops on roses', 'whiskers on kittens', 'bright copper kettles',
                   'warm woolen mittens', 'bright paper packages tied up with string',
                   'cream colored ponies', 'crisp apple strudels']

slice1 = favorite_things[1:4]
slice2 = favorite_things[::-1][0:2]

1 Answer

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! You're doing terrific! Using slices takes some getting used to. You do have the last two things from that list, but they are in the reverse order. Your slice is ['crisp apple strudels', 'cream colored ponies'], but it should be ['cream colored ponies', 'crisp apple strudels']. Instead of reversing the slice and taking the first two, try starting two from the end and going forward. Remember, the first number is indicative of where you want to start and can also contain negative numbers :smiley:

I feel like you will get there with this hint, but let me know if youΒ΄re still stuck! :sparkles: