I am wondering how to handle duplicate characters in my wordle game.
Here is an example of the code:
wordle = "woods"
user_input = input("Enter guess: ")
feedback = []
for i in range(len(wordle)):
if user_input[i] == wordle [i]:
feedback.append("X")
elif user_input[i] != wordle[i] and user_input[i] in wordle:
feedback.append("O")
else:
feedback.append("-")
print()
for let in user_input:
print(let, end=" ")
print()
for char in feedback:
print(char, end=" ")
When the wordle is "woods" and the user input is "sassy", the output should be:
s a s s y
O - - - -
but instead it is:
s a s s y
O - O O -
Another example:
If the wordle is "brass" and the user input is "sassy", the output should be:
s a s s y
O O - X -
but instead it is:
s a s s y
O O O X -
For clarification, "X" is when the letter in the guessed word is also in the target word and is at the same spot. "O" means the letter in the guessed word is also in the target word but isn't at the same spot. "-" means that it's the wrong letter.