Python Python Collections (2016, retired 2019) Lists Removing items from a list

Gia Hoang Nguyen
Gia Hoang Nguyen
4,114 Points

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
173,876 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.

Gia Hoang Nguyen
Gia Hoang Nguyen
4,114 Points

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
173,876 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!