Help! i'm very new to coding and I can't figure this out

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()
print ("Thats not a letter, stupid!")
return letter

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])*
			i += 1
		print (starword)
		print(("Wrong! You lose the %s") % lives[x])
		x += 1


Hi, it would be easier to understand your code if you format it!

You can do this by using the Preformatted Text icon on the toolbar

This will automatically create a code block which you can paste your code in.
Or select your code and then press the icon.

1 Like

I edited the original post, but the code has been pasted with (seemingly) off formatting so it’s not made a great deal of difference.

@mysterylemon0 if you can re-post your code, following @h1lo’s formatting guidelines, we might be able to help (because we’ll be able to run your code as you wrote it).