Created
December 5, 2016 22:53
-
-
Save ProjectJYL/b96f13e9727521569e6f117f312a95ac to your computer and use it in GitHub Desktop.
Exercise: Given two .txt files that have lists of numbers in them, find the numbers that are overlapping. One .txt file has a list of all prime numbers under 1000, and the other .txt file has a list of happy numbers up to 1000. (If you forgot, prime numbers are numbers that can’t be divided by any other number. And yes, happy numbers are a real …
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#File Overlap | |
f1 = open("Documents\primenumbers.txt", "r") | |
f2 = open("Documents\happynumbers.txt", "r") | |
f2_list = f2.readlines() | |
result = list() | |
for line in f1: | |
if line in f2_list: | |
result.append(line.strip() ) | |
f1.close() | |
f2.close() | |
print result |
tried with this program but not working
I think you haven't written the necessary information into the file like prime number and happy number
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
tried with this program but not working