Languages

Python - why is sorted list None?

3 points
Asked by:
marc_so
1104

I am trying to sort a list in Python and it's NoneType, even tho merged variable (consisting of my_list1 and my_list2) is 'list' type.

What is the reason and how can I fix this?

My code:

1 answer
3 points
Answered by:
Admin Dirask Community
4380

The sort() method is sorting in place and that's why the result is None.

Don't assign merged list to the new result variable, just sort it.

In your case it would be:

0 commentsAdd comment
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join