Skip to content

Instantly share code, notes, and snippets.

@scorphus
Created February 18, 2021 23:10
Show Gist options
  • Save scorphus/85d926550fe84e699ae38e1839b8a98d to your computer and use it in GitHub Desktop.
Save scorphus/85d926550fe84e699ae38e1839b8a98d to your computer and use it in GitHub Desktop.
Pattern Matching in Python
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