'How can I account for multiple of the same letter in my wordle game

I'm currently trying to code a wordle game but whenever multiple of the same letter appear in the word i'm inputting but less times in the word i'm trying to guess, all instances of the letter, unless in the correct place will be highlighted as being in the wrong place e.g

If the word I am looking for is latex and I input skull, both "l"s are said to be in the wrong place despite there only being one l

Here is my logic, I use ansi escape sequences for colour:

  while times < 6:
    inp = input("word: ")
    while len(inp) != 5 or inp not in english_words_lower_alpha_set:
      inp = input("not in list: ")
    display = ""
    for x in range(5):
      if inp[x] == word[x]:
        display = display + green + inp[x] + reset
      elif inp[x] in word:
        display = display + yellow + inp[x] + reset
      else:
        display = display + grey + inp[x] + reset


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source