Arun Posted on Mar 15, 2025 Why None? #python #sortfunction #programming #discuss names = ["Eren", "luffy", "goku"] print(names.sort()) Output: None Why the sort method can't sort the list? Top comments (2) Subscribe Submit Preview Dismiss Collapse Expand arccoder arccoder arccoder Follow Location Greater Boston Area Joined Mar 15, 2025 • Mar 15 '25 Dropdown menu Copy link Hide 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 Expand Arun Arun Arun Follow Enthusiastic person in python programming and a beginner in machine learning Joined Mar 15, 2025 • Mar 21 '25 Dropdown menu Copy link Hide Ok Code of Conduct • Report abuse
Top comments (2)
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.Ok