![subject](/tpl/images/cats/informatica.png)
Computers and Technology, 27.03.2021 02:10 vicor
This program reads a file called 'test. txt'. You are required to write two functions that build a wordlist out of all of the words found in the file and print all of the unique words found in the file. Remove punctuations using 'string. punctuation' and 'strip()' before adding words to the wordlist.
Write a function build_wordlist() that takes a 'file pointer' as an argument and reads the contents, builds the wordlist after removing punctuations, and then returns the wordlist. Another function find_unique() will take this wordlist as a parameter and return another wordlist comprising of all unique words found in the wordlist.
Example:
Contents of 'test. txt':
test file
another line in the test file
Output:
['another', 'file', 'in', 'line', 'test', 'the']
This the skeleton for 1:
#build_wordlist() function goes here
#find_unique() function goes here
def main():
infile = open("test. txt", 'r')
word_list = build_wordlist(infile)
new_wordlist = find_unique(word_list)
new_wordlist. sort()
print(new_wordlist)
main()
![ansver](/tpl/images/cats/User.png)
Answers: 3
![](/tpl/images/ask_question.png)
![](/tpl/images/ask_question_mob.png)
Other questions on the subject: Computers and Technology
![image](/tpl/images/cats/informatica.png)
Computers and Technology, 23.06.2019 06:00, ashleyd198308
Respond to the following in three to five sentences. select the workplace skill, habit, or attitude described in this chapter that you believe is most important for being a successful employee.
Answers: 1
![image](/tpl/images/cats/informatica.png)
![image](/tpl/images/cats/informatica.png)
Computers and Technology, 24.06.2019 19:20, boyancecristina
Which command suppresses the visibility of a particular row or column in a worksheet?
Answers: 1
![image](/tpl/images/cats/informatica.png)
Computers and Technology, 25.06.2019 10:40, camidevecchis15
If you're using the paintbrush tool and want to change the color of the paint being used what should you change
Answers: 1
You know the right answer?
This program reads a file called 'test. txt'. You are required to write two functions that build a w...
Questions in other subjects:
![Konu](/tpl/images/cats/health.png)
Health, 17.07.2019 06:28
![Konu](/tpl/images/cats/istoriya.png)
![Konu](/tpl/images/cats/biologiya.png)
![Konu](/tpl/images/cats/istoriya.png)
![Konu](/tpl/images/cats/obshestvoznanie.png)
![Konu](/tpl/images/cats/biologiya.png)
Biology, 17.07.2019 06:28
![Konu](/tpl/images/cats/obshestvoznanie.png)
![Konu](/tpl/images/cats/ekonomika.png)
Business, 17.07.2019 06:28
![Konu](/tpl/images/cats/obshestvoznanie.png)