Skip to content

Commit 1e476ea

Browse files
committed
fix brain_even
1 parent 2b37709 commit 1e476ea

File tree

4 files changed

+17
-13
lines changed

4 files changed

+17
-13
lines changed
230 Bytes
Binary file not shown.

brain_games/scripts/brain_even.py

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,29 @@
11
import random
22

33
def main():
4-
print('Welcome to the Brain Even Game!')
4+
print('Welcome to the Brain Games!')
55
name = input('May I have your name? ')
66
print(f'Hello, {name}!')
7-
8-
rounds = 3
9-
for _ in range(rounds):
10-
number = random.randint(1, 100)
7+
print(f'Answer "yes" if the number is even, otherwise answer "no".')
8+
9+
correct_answers = 0
10+
while correct_answers < 3:
11+
number = random.randint(1, 100) # Генерация случайного числа
12+
print(f"Question: {number}")
13+
answer = input('Your answer: ')
14+
1115
correct_answer = 'yes' if number % 2 == 0 else 'no'
12-
print(f'Question: {number}')
13-
answer = input("Your answer (yes/no): ")
1416

15-
if answer == correct_answer:
16-
print('Correct!')
17+
if answer.lower() == correct_answer:
18+
print("Correct!")
19+
correct_answers += 1
1720
else:
18-
print(f'Wrong! The correct answer was {correct_answer}.')
19-
break
20-
else:
21-
print('Congratulations, you won!')
21+
print(f"'{answer}' is wrong answer ;(. Correct answer was '{correct_answer}'.")
22+
print(f"Let's try again, {name}!")
23+
return # Завершение игры при неправильном ответе
2224

25+
print(f"Congratulations, {name}!") # Поздравление при успешной игре
26+
2327
if __name__ == '__main__':
2428
main()
2529

201 Bytes
Binary file not shown.

dist/hexlet_code-0.1.0.tar.gz

254 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)