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) Lists Removing items from a list

How to create a function that re-arrange the list of number

I finally found a way to complete the the Removing item from list Challenge. I am curious of how to create a function that can rearrange the list of number from smallest to highest. Greatly appreciate for any help.

1 Answer

Steven Parker
Steven Parker
231,236 Points

You can't put two "del" statements on the same line.

But if you put each on a separate line, you'll pass the challenge.

I finally figure out the solution but curious of how to create a function to re-arrange messy_list = [2,3,1] from smallest to biggest. I understand there are multiple way to create this function but my knowledge now is not enough to figure it out. Can you help me Steven?

Thanks Gia

Steven Parker
Steven Parker
231,236 Points

The easy way is to just use the built-in "sort" method:

messy_list.sort()

If the original question has been answered, you can mark it solved by choosing a "best answer".
And happy coding!