while문을 사용하여 blank를 다 채울 때까지 guess를 반복하기
알파벳을 다 맞췄을 때 유저가 이겼다는 것을 알려주기
FOR and IN
squares = [1, 4, 9, 16]
sum = 0
for num in squares:
sum += num
print(sum) ## 30
list = ['larry', 'curly', 'moe']
if 'curly' in list:
print('yay')
in은 for과 if문에 사용 가능 (while문에 사용X)
end_of_game = False
while not end_of_game:
guess = input("Guess a letter: ").lower()
for position in range(word_length):
letter = chosen_word[position]
if letter == guess:
display[position] = letter
print(display)
if '_' not in display:
end_of_game = "True"
print("Win!")
print(display)
'코딩 공부 > Python' 카테고리의 다른 글
Hangman Step4 (0) | 2023.01.24 |
---|---|
Hangman Step2 (0) | 2023.01.20 |
Data Type (0) | 2022.12.27 |
boot camp1 (0) | 2022.12.24 |