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


list = list.sort()

I know the proper way to sort a list is just doing list.sort(), but I was wondering what is happening behind the scenes when you try to do something like list = list.sort()

When I do that and try to print list, I just get 'None' and I'm just curious what is happening for that to happen.

1 Answer

Steven Parker
Steven Parker
229,920 Points

The "sort" method sorts the list, but doesn't return anything (so "None").
But there's another method you could use that does return the sorted list (instead of changing it directly):

list = list.sorted()