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, 22.06.2019 19:20
How might the success of your campaign be affected if you haven’t carefully completed all field data or if you accidentally insert the wrong merge field in the document?
Answers: 2
question
Computers and Technology, 23.06.2019 00:30
Which one of the following is considered a peripheral? a software b mouse c usb connector d motherboard
Answers: 2
question
Computers and Technology, 23.06.2019 21:40
Draw the resistor’s voltage and current phasors at t=15ms. draw the vectors with their tails at the origin. the orientation of your vectors will be graded. the exact length of your vectors will not be graded.
Answers: 2
question
Computers and Technology, 24.06.2019 02:10
Aspeed limit sign that says "night" indicates the legal speed between sunset and sunrise.
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, 30.05.2021 19:30
question
English, 30.05.2021 19:30
Questions on the website: 13722361