Created
February 27, 2018 11:09
-
-
Save umair-tp/113cfeac14283896047da34a38912183 to your computer and use it in GitHub Desktop.
Exercise 23 : 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 r…
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
| with open('primenumbers.txt') as prime_file: | |
| prime_nums = prime_file.read().split('\n') | |
| with open('happynumbers.txt') as happy_file: | |
| happy_nums = happy_file.read().split('\n') | |
| for prime_num in prime_nums: | |
| if prime_num in happy_nums: | |
| print prime_num |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment