ฉันสามารถตรวจสอบได้ว่าสิ่งfindUniqueWordsนั้นส่งผลให้เกิดการเรียงลำดับ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 เรียงลำดับ (theSet) `