subject

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 fileanother line in the test fileoutput: ['another', 'file', 'in', 'line', 'test', 'the']this the skeleton for 1: #build_wordlist() function goes here#find_unique() function goes heredef main(): infile = open("test. txt", 'r')word_list = build_wordlist(infile) new_wordlist = find_unique(word_list)new_wordlist. sort()print(new_wordlist)main()2-wr ite a function called 'game_of_eights()' that accepts a list of numbers as an argument and then returns 'true' if two consecutive eights are found in the list. for example: [2,3,8,8,9] -> true. the main() function will accept a list of numbers separated by commas from the user and send it to the game_of_eights() function. within the game_of_eights() function, you will provide logic such that: the function returns true if consecutive eights (8) are found in the list; returns false otherwise. the function can handle the edge case where the last element of the list is an 8 without crashing. the function prints out an error message saying 'error. enter only integers.' if the list is found to contain any non-numeric characters. note that it only prints the error message in such cases, not 'true' or 'false'.examples: enter elements of list separated by commas: 2,3,8,8,5trueenter elements of list separated by commas: 3,4,5,8falseenter elements of list separated by commas: 2,3,5,8,8,uerror. enter only integers. hint: you will need to use try-except to catch exceptions. this is the skeleton for 2: #game_of_eights() function goes heredef main(): a_list = input("enter elements of list separated by commas: ").split(',')result = game_of_eights(a_list)main()

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 04:31
Q13 what function does a security certificate perform? a. creates user accounts b. scrambles data c. identifies users d. creates password policies e. provides file access
Answers: 1
question
Computers and Technology, 23.06.2019 06:00
When is a chart legend used a. all the time b. whenever you are comparing data that is the same c. whenever you are comparing multiple sets of data d. only for hand-drawn charts
Answers: 2
question
Computers and Technology, 23.06.2019 12:40
According to the video what are some tasks petroleum engineers perform check all that apply
Answers: 2
question
Computers and Technology, 23.06.2019 14:00
What is html ? give a small description about html
Answers: 2
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
question
Mathematics, 02.12.2020 20:00
question
Mathematics, 02.12.2020 20:00
question
Mathematics, 02.12.2020 20:00
question
Chemistry, 02.12.2020 20:00
question
Mathematics, 02.12.2020 20:00
question
Mathematics, 02.12.2020 20:00
Questions on the website: 13722363