Em đang học python 3 trên trang web www.py4e.com của Dr. Charles Russell Severance
Chỉ em hướng giải quyết bài này.
Exercise 4: Download a copy of the file from www.py4e.com/code3/romeo.txt.
Write a program to open the file romeo.txt and read it line by line. For each line, split the line into a list of words using the split function.
For each word, check to see if the word is already in a list. If the word is not in the list, add it to the list.
When the program completes, sort and print the resulting words in alphabetical order.
— Làm sao được đáp án như này ạ:
Enter file: romeo.txt
['Arise', 'But', 'It', 'Juliet', 'Who', 'already', 'and', 'breaks', 'east', 'envious', 'fair', 'grief', 'is', 'kill', 'light', 'moon', 'pale', 'sick', 'soft', 'sun', 'the', 'through', 'what', 'window', 'with', 'yonder']