4 ms·
findall and multiline mode makes it even easier, at the cost of loading whole file into memory though, for that reason your alternaive is probably better i
by Too 4y ago
findall and multiline mode makes it even easier, at the cost of loading whole file into memory though, for that reason your alternaive is probably better
import re
wordlist = open("/usr/share/dict/words").read()
for word in re.findall(r"^[a-foi]{6}$", wordlist, re.IGNORECASE | re.MULTILINE):
hexword = word.upper().replace("O", "0").replace("I", "1")
print(f"#{hexword}")