I am trying to build an algorithm to solve wordles. I am asking python to identify if there are black or yellow characters and remove possible 5 letter words from a list I made using nltk if they contain black characters or fail to contain yellow characters (black means delete the word from list, yellow means delete words that don't contain yellow characters from the list).
Python seems to skip entirely over the last part of my code as when I print five_letter_words it's the full list I started with. This is my code, can anyone help?
import nltk
from nltk.corpus import words
five_letter_words =[]
for s in words.words():
if len(s) == 5 and s[0].isupper() == False:
five_letter_words.append(s)
word_answer = {"t":"b", "r":"b", "e":"b", "a":"b", "d":"b"}
yellow = []
black = []
solved = False
while solved == False:
for c in word_answer:
word_answer[c] = [*input("Color:")]
if word_answer[c] == ['y']:
yellow.append(c)
if word_answer[c] == ['b']:
black.append(c)
for w in five_letter_words:
for c in black:
if c in w == True:
five_letter_words.remove(w)
for c in yellow:
if c in w == False:
five_letter_words.remove(w)
for i in word_answer:
word_list = [x for x in w]
for x in word_list:
if word_answer[i] == 'g' and word_list[x] != i:
five_letter_words.remove(w)
solved = True
print(five_letter_words)