findUniqueWords
결과가 sorted 인 것을 확인할 수있었습니다 list
. 그러나 목록을 반환하지 않습니다. 왜?
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
theSet= set(theList)
목록으로 다시 캐스팅하기 theList = list(theSet)
만하면됩니다. 완료. 쉬운.
theSet' into a sorted list with
sorted (theSet)`를 변환 할 수 있습니다 .