So I just started experimenting with python and I've learned a few commands with which Im trying to create a hangman-game. If the player finds a letter for the 1st time the program works fine and displays the missing letters as '_', showing the letter in the correct spot. However if the player finds a 2nd letter, the word will just reset and show up just the 2nd letter in its potisionand the missing letters as ' _'. Is there a command that can help me deal with this. Ive used this code for that section
word = input('Give word:\n')
word = word[0].upper()+word[1:]
wordC =word[1:-1]
wordUkn = ' _ '*len(wordC)
while '_' in wordUkn and mist < 3 :
ans=input('Give a letter:\n')
if ans in wordC :
pos=wordC.index(ans)
wordUkn=(' _ '*pos)+str(ans)+' _ '*(len(wordC)-(pos+1))
print(word[0]+wordUkn+word[-1])
mist = mistakes ans=answer
Also If Im new here so If there is anything I should be doing differently about posting questions please inform me. I would also aprreciate it,If anyone could tell me how to deal with the case that the world contains the same letter 2 times. Thanks for your time. :)