Using replace instead of find
<p>I have written the following piece but not able to figure the next part:</p>

<pre><code>if request.guess in game.target:            
  position = game.target.find(request.guess)
  game.correct[position] = request.guess.upper()
</code></pre>

<p>The point here is <code>request.guess</code> is a character input like <code>'a'</code> and <code>game.target</code> is <code>'austin'</code>. So the above code will find the character in the target word and generate an output like <code>a*****</code>. But my code will only work for words that have letters not repeated in them eg: Australia. I know there is a method 'replace' in python but I am not able to figure out how should I incorporate here.</p>

<p>Kindly help!!!!!</p>

<p>just use a set of guessed letters and do something like the below.</p>

<pre><code>In [164]: word = 'Australia'
In [165]: guessed = set()
In [166]: guessed.add('a')
In [167]: print(''.join(c if c.lower() in guessed else '*' for c in word))
A****a**a
</code></pre>

python python-3.x