import random
import time
import sys
import os
if os.name == 'nt':
from ctypes import windll
k = windll.kernel32
k.SetConsoleMode(k.GetStdHandle(-11), 7)
keys = {'a': 'NSr', 'b': 'rlK', 'c': 'yDD', 'd': 'YBr', 'e': 'XBB', 'f': 'LLo', 'g': 'gZn', 'h': 'LTd', 'i': 'hKn', 'j': 'fWj', 'k': 'dgu', 'l': 'nFN', 'm': 'nNy',
'n': 'QKD', 'o': 'cJJ', 'p': 'MEA', 'q': 'WTJ', 'r': 'nnM', 's': 'Tru', 't': 'xcE', 'u': 'Msx', 'v': 'Cef', 'w': 'Hkf', 'x': 'obn', 'y': 'myp', 'z': 'PUE'}
keyr = {v: k for k, v in keys.items()}
def encrypt(text):
if len(text) > 1:
string = ""
for char in text:
if char in keys:
string += keys[char] + ","
else:
return "Only letters are allowed"
break
return string
else:
return "Text must have something in it"
def decrypt(text):
text = text[:-1].split(",")
if len(text) > 1:
string = ""
for char in text:
if char in keyr:
string += keyr[char]
else:
return "Only letters are allowed"
break
return string
else:
return "Text must have something in it"
print("Welcome to Wordle!")
print("Random or Custom Word?")
ch = input("Type 'r' or 'c' ")
if ch not in ("r", "c"):
while ch not in ("r", "c"):
ch = input("Type 'r' or 'c' ")
green = "u001b[32m"
yellow = "u001b[33m"
reset = "u001b[0m"
if ch == "r":
letters = "abcdefghijklmnopqrstuvwxyz"
ln = {}
for char in letters:
ln[char] = 0
words = open("words.txt", "r")
wordl = []
for item in words.readlines():
wordl.append(item.strip())
word = wordl[random.randint(0, 5756)]
print(f'Your word is 5 letters. Start guessing!')
num = 1
correct = False
while num < 6:
guess = input(f'Guess {str(num)}: ').lower()
sys.stdout.write("