File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change 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." )
You can’t perform that action at this time.
0 commit comments