I'm trying to make something in python where you put the amount of letters in a word then it searches in a word list for words with that amount of chars.
My code:
import sys
import re
def search(pattern):
print("Searching...\n\n")
for i, line in enumerate(open(sys.argv[1])):
for match in re.finditer(pattern, line):
print(match.groups())
print("\n\nFinished.")
while True:
word = ""
put = int(input("Amount of Letters in Word: "))
if put > 25 or put < 3:
print("Invalid amount of letters.")
else:
for n in range(0, put):
word = word + "."
word = "^" + word + "$"
pattern = re.compile(word)
search(pattern)
I want it to show all words with the amount of letters that you put.
https://i.imgur.com/Kgusvyh.png
List of words:
word
1234
okay
0000
asdfg
asdfh
asdgj
Why does it show ()?