DEV Community

Arun
Arun

Posted on

Why None?

names = ["Eren", "luffy", "goku"]
print(names.sort())
Output: None
Why the sort method can't sort the list?

Top comments (1)

Collapse
 
arccoder profile image
arccoder

It's sorting the list however not returning anything, that's why None.
If you want the sorted list to be returned, use sorted() method.

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay