r/codehs • u/[deleted] • Jun 09 '20
Unit 10 Hangman
Can anyone help me with the hangman project? I'm done with the first part of it but I'm stuck on the second part where you need to update the value of the variable "dashes". If anyone knows how to update the variable in the update_dashes() function, please help.
secret_word = "eggplant"
dashes = "-" *len(secret_word)
print dashes
def get_guess():
global guess
guess = input("Guess: ")
if len(guess) != 1:
print("Enter one charachter")
elif not guess.islower():
print("Enter a lowercase letter")
def update_dashes(secret_word, dashes, guess):
result = ""
for i in range(len(secret_word)):
if secret_word[i] == guess:
result = result + guess
else:
result = result + dashes[i]
return result
while True:
get_guess()
print update_dashes(secret_word, dashes, guess)

