add wordle.py, wordle implimentation

This commit is contained in:
randomuser 2022-02-07 13:54:29 -06:00
parent e4aaff1f0b
commit 2d58cb1cac
1 changed files with 22 additions and 0 deletions

22
wordle.py Normal file
View File

@ -0,0 +1,22 @@
#!/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))