How do I replace the starword space to the letter they guessed correctly? I’m doing handman and everything is working correctly up until the bolded portion. Any and all help would be appreciated. Sorry for the clutter.
from random import choice print ("GAME START!! Welcome to hangman! Guess letters of the word to win! You have 5 tries to win.") ##Random words, I'm going to expand a little bit to import a dictionary so I can put more words and more complicated words. But for right now whats below this gets a random words from the list and wordchoice = ['popcorn', 'cats', 'county', 'grand canyon'] lives = ['left arm', 'left leg', 'right arm', 'right leg', 'head'] randomword = choice(wordchoice) starword = '*' * len(randomword) print(("Your word is %d letters long!") % len(randomword)) def ask(): global letter letter = input("What letter is first? : ") if letter.isalpha(): letter = letter.lower() else: print ("Thats not a letter, stupid!") ask() return letter ask() def check(): global x global i x = 0 i = 0 if letter in randomword: print ("Yay!") if randomword[i] == letter: *str.replace(starword[i], randomword[i])* else: i += 1 else: print (starword) print(("Wrong! You lose the %s") % lives[x]) x += 1 check() print(starword)