wordlefish/wordle.py

23 lines
616 B
Python
Raw Normal View History

2022-02-07 13:54:29 -06:00
#!/usr/bin/python3
import random
words = [i.rstrip() for i in open("wordlist", "r").readlines()]
word = random.choice(words)
while True:
line = input("? ")
out = []
if line == "new":
word = random.choice(words)
else:
for i in range(5):
if line[i] == word[i]:
out.append("\033[102;97m {} \033[0m".format(line[i]))
elif line[i] in word:
out.append("\033[103;97m {} \033[0m".format(line[i]))
elif not line[i] in word:
out.append("\033[47;97m {} \033[0m".format(line[i]))
print(''.join(out))