I'm getting started with coding and I tried to programm "Hangman". Now I figured most of the stuff on my own, but I'm struggling with this one.I want to save multiple indexes, so that i can replace "_" to the needed character.
guess = ""for x in randomWord: guess = str(guess) +"_"#Calculates the index for the found lettefor i in randomWord: wordIndex = randomWord.find(userInput)#If Statement deconstructs string into list and adds found letter if wordIndex > -1: guess = list(guess) guess[wordIndex] = userInput guess = "".join(guess) missLett -= 1
I read somewhere, that enumerate could help me with my problem, but just couldn't get the hang of it.