相关疑难解决方法(0)

为什么"return list.sort()"返回None,而不是列表?

我已经能够验证findUniqueWords确实导致排序list.然而,它没有findUniqueWordslist,为什么呢?

def findUniqueWords(theList):
    newList = []
    words = []

    # Read a line at a time
    for item in theList:

        # Remove any punctuation from the line
        cleaned = cleanUp(item)

        # Split the line into separate words
        words = cleaned.split()

        # Evaluate each word
        for word in words:

            # Count each unique word
            if word not in newList:
                newList.append(word)

    answer = newList.sort()
    return answer
Run Code Online (Sandbox Code Playgroud)

python sorting return list

126
推荐指数
7
解决办法
11万
查看次数

标签 统计

list ×1

python ×1

return ×1

sorting ×1