틀렸을 때 패널티를 주자
while not end_of_game:
guess = input("Guess a letter: ").lower()
#Check guessed letter
for position in range(word_length):
letter = chosen_word[position]
# print(f"Current position: {position}\n Current letter: {letter}\n Guessed letter: {guess}")
if letter == guess:
display[position] = letter
#TODO-2: - If guess is not a letter in the chosen_word,
#Then reduce 'lives' by 1.
#If lives goes down to 0 then the game should stop and it should print "You lose."
else:
lives -= 1
else문을 추가하면 _갯수마다 lives가 까여서 한 번 틀릴 때마다 -1이상 까임
for문에서 벗어난 if문을 새로 만들자
'코딩 공부 > Python' 카테고리의 다른 글
Hangman Step3 (0) | 2023.01.24 |
---|---|
Hangman Step2 (0) | 2023.01.20 |
Data Type (0) | 2022.12.27 |
boot camp1 (0) | 2022.12.24 |