-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwordcheck.py
More file actions
27 lines (25 loc) · 775 Bytes
/
wordcheck.py
File metadata and controls
27 lines (25 loc) · 775 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import re
file = open("words_alpha.txt","r")
words=file.readlines()
badLetters = r"[gkmqvwxz]"
longestWord=[]
maxLength=0
for line in words:
line=line.strip()
if re.search(badLetters, line, re.IGNORECASE):
## print(line+" - Has Bad Letters")
continue
elif len(line)<maxLength:
## print(line+" - Too short!")
continue
else:
if len(line)==maxLength:
longestWord.append(line)
print(line+" - OK! - Same length as previous longest.")
print("Current longest words - ")
print(longestWord)
else:
longestWord.clear()
print(line+" - OK! - NEW LONGEST")
longestWord.append(line)
maxLength=len(line)