add wordle.py, wordle implimentation
This commit is contained in:
parent
e4aaff1f0b
commit
2d58cb1cac
|
@ -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))
|
||||
|
Loading…
Reference in New Issue