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

venkat bogadi
venkat bogadi
1,031 Points

kindly help me out regarding this

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[5:] soreted_things=favorite_things sorted_things.sort() please correct me if anything wrong

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[5:]
soreted_things=favorite_things
sorted_things.sort()

the problem is these are not your favorite things

Steven Parker
Steven Parker
231,269 Points

Jean y — funny! :smirk:

But keep in mind that folks posting questions may be experiencing frustration and might not be the best audience for comedy. I learned that lesson myself when attempts to inject humor into my answers (which also contained helpful hints) were misinterpreted and resulted in complaints of "abrasive", "demeaning" or just "lacking empathy". Hopefully my experience will be of value to you also.

2 Answers

Steven Parker
Steven Parker
231,269 Points

Very close! But I see two issues:

  • you have "soreted_things" (with an extra "e") instead of "sorted_things"
  • a simple assignment of a list makes a duplicate reference, but doesn't copy the list

Two easy ways to copy a list are using the ".copy()" method or a slice with no arguments ("[:]").