Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Python Collections (2016, retired 2019) Slices Back and Forth

please help im lost here

how do i sort my sorted things list

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 = ['whiskers on kittens', 'bright copper kettles', 'warm woolen mittens']
slice2 = ['cream colored ponies', 'crisp apple strudels']
sorted_things = ['raindrops on roses', 'whiskers on kittens', 'bright copper kettles',
                 'warm woolen mittens', 'bright papper packeges tied with string',
                'warm colored ponies', 'crisp apple strudels']
sorted_things.sort()

2 Answers

Challenge 1: You need to start from index 1(second item) until index 4(not included)

slice1 = favorite_things[1:4]

Challenge 2: (Last 2 element)

slice2 = favorite_things[-2:]

Challenge 3: First copy the old one to sorted_things, then use the sort() method

sorted_things = favorite_things[:]
sorted_things.sort()

so I'm stuck on Challenge 2. I tried what you said here after I tried doing [5:7] but its still says that task 1 is no longer passing. Any Ideas?

It's being picky and doesn't like that you manually created a copy of favorite_things instead of doing it programmatically. If you use the slice method of copying new_list = old_list[:] to create your sorted_things that way, you'll be good.