Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- lives = 9
- words = ['пицца', 'выдра', 'кошка', 'питон']
- secret_word = random.choice(words)
- secret = ['?'] * 5
- heart = u'\u2764'
- correct_ans = False
- while lives > 0:
- print(secret)
- print('Осталось жизней: ' + heart * lives)
- ans = input('Угадайте букву или слово целиком\n')
- if ans == secret_word:
- correct_ans = True
- break
- if ans in secret_word:
- for index in range(5):
- if secret_word[index] == ans:
- secret[index] = ans
- if not '?' in secret:
- correct_ans = True
- break
- else:
- print('Вы угадали одну букву')
- else:
- print('Неправильно! Вы теряете жизнь')
- lives = lives - 1
- if correct_ans == True:
- print('Победа!')
- else:
- print('Вы проиграли! Было загадано слово', secret_word)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement