I am coding for a game similar to wordle I need to compare 2 strings
- If the character and position is the same to return
- - If the character in
guessis in theanswerbut wrong position to return* - If character completely not in
answerto return.
If my answer has 2 similar characters (eg, guess: accept, answer: castle), * can only be returned once, meaning the expected output would be **.*.*
I can't seem to iterate the string taking into account the position as well
def process(guess: str, answer: str) -> str:
output = ""
for i,ch in enumerate(guess):
if ch not in answer:
output += '.'
elif ch != answer[i]:
output += '*'
else:
output += '-'
return output