# i have already imported all necessary libraries and it is randomly choosing a word
word_list = r.get_random_word()
chosen_one = word_list
input_rect = pygame.Rect(200, 200, 140, 32)
base_font = pygame.font.Font(None, 32)
user_text = ""
user_words = ""
###
counter_text = 0
list_of_words = []
###
#check_spelling = spell.unknown(word_list)
#print(check_spelling)
while running:
# poll for events
# pygame.QUIT event means the user clicked X to close your window
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
if event.type == pygame.MOUSEBUTTONDOWN:
if input_rect.collidepoint(event.pos):
active = True
else:
active = False
if event.type == pygame.KEYDOWN:
# get the correct word to append to user words and change user text back to empty
if event.key == pygame.K_RETURN:
# This array takes the current user_input and stores in array
list_of_words.append(user_text)
# This loop takes the word in the array and checks if it is correct
for word in list_of_words:
# This actually checks if it is correct by comparing original and newly corrected word
user_words = spell.correction(word)
# If the word is actually correct, run etc.
if word == user_words:
# split the word into letters for single-use
# all possible words exist in chose_one
letter_array = [] # ["a", "p", "p", "l", "e"]
for i in chosen_one:
letter_array.append(i)
# If the word when user types enter, is not in the word, automatically say wrong letters in text
for j in range(len(word)):
# go through each letter and compare in the array
if word[j] in letter_array:
if j == (len(word) - 1):
# go through each letter and check if the last letter equals the current letter
word += user_words
user_text = ""
counter_text += 1
else:
print(j, word, letter_array)
user_text = "That's not a letter in the word, try again."
break
else:
user_text = "That's not a word, try again."
I was trying to make a game that takes a random word for example "mountains" and you make as many word as you can out of that one word with only those letters for example here with "mountains" you could make "tin" "stain" "mount" "tan" etc. and every time you get a word correct you add 1 to the counter box if the letters aren't in the word say so and if its not a word say so the current issue is it only correctly does that once and I don't know why