File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import sys
2+ import random
3+ from enum import Enum
4+
5+
6+ class RPS (Enum ):
7+ ROCK = 1
8+ PAPER = 2
9+ SCISSORS = 3
10+
11+
12+ print ("" )
13+ playerchoice = input (
14+ "Enter...\n 1 for Rock,\n 2 for Paper, or \n 3 for Scissors:\n \n " )
15+
16+ player = int (playerchoice )
17+
18+ if player < 1 | player > 3 :
19+ sys .exit ("You must enter 1, 2, or 3." )
20+
21+ computerchoice = random .choice ("123" )
22+
23+ computer = int (computerchoice )
24+
25+ print ("" )
26+ print ("You chose " + str (RPS (player )).replace ('RPS.' , '' ) + "." )
27+ print ("Python chose " + str (RPS (computer )).replace ('RPS.' , '' ) + "." )
28+ print ("" )
29+
30+ if player == 1 and computer == 3 :
31+ print ("π You win!" )
32+ elif player == 2 and computer == 1 :
33+ print ("π You win!" )
34+ elif player == 3 and computer == 2 :
35+ print ("π You win!" )
36+ elif player == computer :
37+ print ("π² Tie game!" )
38+ else :
39+ print ("π Python wins!" )
You canβt perform that action at this time.
0 commit comments