Created
February 18, 2021 23:10
-
-
Save scorphus/85d926550fe84e699ae38e1839b8a98d to your computer and use it in GitHub Desktop.
Pattern Matching in Python
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("/usr/share/dict/words") as words: | |
for word in map(str.rstrip, words): | |
for letter in word: | |
match letter: | |
case "a" | "b" | "c" | "d" | "e" | "f": | |
continue | |
case _: | |
break | |
else: | |
print(word) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment