Skip to content

Commit 984d0f9

Browse files
committed
Update ex068.py
1 parent c6e3a80 commit 984d0f9

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

ex068.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,28 @@
11
# Make a program that plays odd or even with the computer. The game will only stop when the player loses, showing the
22
# total number of consecutive wins he has achieved at the end of the game.
3+
from random import randint
4+
w = 0
5+
while True:
6+
player = int(input("Enter a number:"))
7+
computer = randint(0,10)
8+
total = player + computer
9+
tpe = ' '
10+
while tpe not in "EO":
11+
tpe = str(input("Ear or odd? [E/O]")).strip().upper()[0]
12+
print(f"You played {player} and the computer {computer}. the total is {total}")
13+
if tpe == "E":
14+
if total % 2 == 0:
15+
print("You Win!")
16+
w += 1
17+
else:
18+
print(" You Lost!!")
19+
break
20+
elif tpe == "O" :
21+
if total % 2 == 1:
22+
print("You Win!")
23+
w += 1
24+
else:
25+
print("You lost!!")
26+
break
27+
print("Let's play again...")
28+
print(f"You win {w} times.")

0 commit comments

Comments
 (0)