Created
April 10, 2020 15:39
-
-
Save johnholbrook/59cb553792bc1fa932e3cb76cd4315be to your computer and use it in GitHub Desktop.
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
| #returns true if strings a and b contain the same letter count | |
| # (i.e., a can be rearranged to form b) | |
| def compare(a,b): | |
| return sorted([i for i in a]) == sorted([i for i in b]) | |
| def main(): | |
| contents = [] | |
| # open the file and separate into lines | |
| with open("enable1.txt", "r") as f: | |
| contents = f.readlines() | |
| # strip trailing \n (not sure why it's there after the call to readlines but whatever) | |
| contents = [word[:-1] for word in contents] | |
| target = "streampa" | |
| for word in contents: | |
| if compare(word, target): | |
| print(word) | |
| if __name__ == "__main__": | |
| main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment