Jun-04-2020, 11:57 AM
Python 3.6.5
I've created a hangman game in Python and I'm trying to debug an error:
The game works in a way that randomly picks a word from a list, stars out the word (using two separate variable names), and then each time a letter is guessed correctly, the star is replaced with the correct letter in the correct position. However, for instance the word "seen". If you correctly guess the letter "e" it will populate the guess as *e**. It will not add two e's. This is because I'm using the .find() function, which stops after finding the correct letter:
thank you!
I've created a hangman game in Python and I'm trying to debug an error:
The game works in a way that randomly picks a word from a list, stars out the word (using two separate variable names), and then each time a letter is guessed correctly, the star is replaced with the correct letter in the correct position. However, for instance the word "seen". If you correctly guess the letter "e" it will populate the guess as *e**. It will not add two e's. This is because I'm using the .find() function, which stops after finding the correct letter:
if guess in full_word: #replacing the * in selected_word with the guessed letter that was correct checker = full_word.find(guess) selected_word = selected_word[:checker] + guess + selected_word[checker+1:]can anyone offer any advice that allows the program to check multiples of the same letter?
thank you!