Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ch 8 p 10 - Judah Mismash
- #print common words from two text files.
- def main() :
- #Read the files.
- words1 = fileWords()
- words2 = fileWords()
- common = words1.interesction(words2)
- print("Common words: ")
- for word in sorted(common) :
- print(" ", word)
- def fileWords() :
- filename = input("Please enter the text file name: ")
- inf = open(filename, "r")
- words = set()
- for line in inf :
- parts = line.split()
- for word in parts:
- words.add(word)
- return words
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement