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 (2)

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.

Collapse
 
arun04hack profile image
Arun

Ok