-
Notifications
You must be signed in to change notification settings - Fork 0
/
exercise068.py
31 lines (28 loc) · 807 Bytes
/
exercise068.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from random import randint
v = 0
while True:
player = int(input('Enter a value: '))
computer = randint(0, 10)
total = player + computer
typ = ' '
while typ not in 'PO':
typ = str(input('Even or odd? [P/O] ')).strip().upper()[0]
print(
f'You played {player} and the computer {computer}. Total gave {total}', end='')
print(' gave pair' if total % 2 == 0 else ' gave odd')
if typ == 'P':
if total % 2 == 0:
print('You won!')
v += 1
else:
print('You lost!')
break
elif typ == 'O':
if total % 2 == 1:
print('You won!')
v += 1
else:
print('You lost!')
break
print("Let's play again...")
print(f'Game over! You won {v} times')