-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrps.py
More file actions
46 lines (36 loc) · 1.51 KB
/
rps.py
File metadata and controls
46 lines (36 loc) · 1.51 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#Rock Paper Scissors, Exercise 2.2
# Name: Laser Nite
# Kerberos: nite
# Date: 1/6/19
# homework_1.py
# Request Player 1 and Player 2 inputs, "rock, paper, or scissors"
p1 = raw_input("Player 1? ").lower()
p2 = raw_input("Player 2? ").lower()
# Define possible choices in game
choices = ["rock", "paper", "scissors"]
# Determine winner of rock, paper, scissors game
if p1 in choices and p2 in choices:
# If Player 1 and 2 have same selection they tie
if p1 == p2:
print "Player 1 and Player 2 tie!"
# If Player 1 is rock, Player 1 wins if Player 2 is scissors and loses if Player 2 is paper
elif p1 == "rock" and p2 == "scissors":
print "Player 1 Wins!"
elif p1 == "rock" and p2 == "paper":
print "Player 2 Wins!"
# If Player 1 is scissors, Player 1 wins if Player 2 is paper and loses if Player 2 is rock
elif p1 == "scissors" and p2 == "rock":
print "Player 2 Wins!"
elif p1 == "scissors" and p2 == "paper":
print "Player 1 Wins!"
# If Player 1 is paper, Player 1 wins if Player 2 is rock and loses if Player 2 is scissors
elif p1 == "paper" and p2 == "scissors":
print "Player 2 Wins!"
elif p1 == "paper" and p2 == "rock":
print "Player 1 Wins!"
#This else statement should be impossible to activate- a bug check
else:
print "You have discovered a bug! Email me @ nite@mit.edu"
# A player entered an invalid choice
else:
print "Invalid selection: Choose rock, paper, or scissors."