I need the dashes to return but it will not. I even called upon the function. It prints dashes inside the function, but outside it does not.
The point of the code is to have a person guess a letter and return the unknown word with the guest letter in it, if the guested letter is in the word. This is called Hangman in Codehs.
def get_guess():
while True:
guess = input("Guess: ")
if not guess.islower():
print “Your guess must be a lowercase letter!”
elif len(guess) != 1:
print “Your guess must have exactly one character!”
else:
return guess
def update_dashes(word, dashes, guess):
for i in range(len(word)):
if word[i] == guess:
dashes = dashes[:i] + guess + dashes[i+1:]
return dashes
word = “hello”
dashes = “-”*len(word)
while True:
print dashes
guess = get_guess()
update_dashes(word, dashes, guess)
if guess in word:
print “That letter is in the secret word!”
else:
print “That letter is not in the secret word.”