subject
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
Answers: 3

Other questions on the subject: Computers and Technology

image
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
Computers and Technology, 23.06.2019 11:30, kieante01
The most accurate readings that you can take on an analog vom are when the meter's pointer is at the a. center scale. b. extreme right. c. near right. d. extreme left.
Answers: 1
image
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
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: