Question
need help with this python program:please dont use recursion or regex, use set operations like the directions say below :) Write a program that reads
need help with this python program:please dont use recursion or regex, use set operations like the directions say below :)
Write a program that reads 2 text files and compares them in the following ways:
-
Display the length of the list of all the unique words in each file
-
Display the length of the list of the unique words that appear in both files
-
Display the length of the list of the unique words that appear in the first file but not the second.
-
Display the length of the list of the unique words that appear in the second file but not the first.
-
Display the length of the list of the unique words that appear in either the first or second files, but not in both.
Use set operations to do this program. Start off by writing a function that takes the name of a file to read and returns the set of unique words found in that file. Note that you will need to strip blanks, commas, periods, dashes, double quotes, and colons from each word. You will also need to only keep lower case words in your sets. The main function will call this function twice to read the two files and get the two sets containing all the unique words from each file. Then main will use set operations to accomplish the bullet list above.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started