如何结束这场比赛?如果整个单词都猜对了,或者您失去了一生,但如果有人一个个地猜出所有字母,我将无法结束。
secret_word = "something".upper()
lifes = u'\u2764'
total_lifes = 5
print("You have 5 lifes in total to guess the answer")
guess = None
for_list = "?"*len(secret_word)
my_list = list(for_list)
def change_user_output(value):
for j in range(0, len(secret_word)):
if (value == secret_word[j]):
my_list[j] = value
new_user_output = " ".join(my_list)
print(new_user_output)
while total_lifes > 0:
print(lifes * total_lifes)
print("Guess any letter : ")
guess = input().upper()
if(guess == secret_word):
print("WOW that is correct, the secret word is %s"%secret_word)
break
if(guess in secret_word):
print("You guessed it right %s is in SECRET WORD"%guess)
change_user_output(guess)
else:
print("There is no such letter in the SECRET WORD, you loose a life")
change_user_output(guess)
total_lifes -= 1
if total_lifes == 0:
print("You've lost all lifes, GAME OVER FOR YOU")
print("The SECRET WORD was : %s"%"".join(secret_word))