Why does “return list.sort()” return None, not the list?

前端 未结 7 728
感情败类
感情败类 2020-11-21 06:55

I\'ve been able to verify that the findUniqueWords does result in a sorted list. However, it does not return the list. Why?

def fin         


        
7条回答
  •  滥情空心
    2020-11-21 07:34

    list.sort sorts the list in place, i.e. it doesn't return a new list. Just write

    newList.sort()
    return newList
    

提交回复
热议问题