Hi, beginner here.
Doing a hangman game and i am stuck because when i run my function guess_me, the return value is always new. how am i able to store this value into somewhere so that when the function runs again it will be updated?
current code prints out:
a_ _ _ _
_ p p _ _
desired code:
a_ _ _ _
app_ _
Many thanks in advance
Doing a hangman game and i am stuck because when i run my function guess_me, the return value is always new. how am i able to store this value into somewhere so that when the function runs again it will be updated?
current code prints out:
a_ _ _ _
_ p p _ _
desired code:
a_ _ _ _
app_ _
Many thanks in advance
secret_word = 'apple'
guesses = []
def guess_me(secret_word, letters_guessed):
word_print = ''
for i in secret_word:
if i in letters_guess:
word_print += i
else:
word_print += '_ '
return word_print
x = 6
while x>0:
letters_guess = input("enter: ")
hmm = guess_me(secret_word, letters_guess)
if letters_guess in secret_word:
guesses.append(letters_guess)
print('good guess')
else:
print("bad one")
