-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRPS.py
More file actions
62 lines (51 loc) · 1.94 KB
/
Copy pathRPS.py
File metadata and controls
62 lines (51 loc) · 1.94 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import random as rd
print("Welcome to Rock Paper Scissors, Python Edition!")
humanScore = 0
computerScore = 0
running = True
while running:
player = input("Choose Rock, Paper, or Scissors ")
computerPlay = rd.randint(0,2)
yesValues = ["y", "yes", "true", "t"]
def yn(val):
return val.lower() in yesValues
rock = ["rock", "r"]
paper = ["paper", "p"]
scissors = ["scissors", "s", "scissor"]
humanPlay = 3
humanMove = ""
convertedFails = 0
possibleHumanPlays = [rock, paper, scissors]
possibleComputerPlays = ["Rock", "Paper", "Scissors"]
computerMove = possibleComputerPlays[computerPlay]
def convertPlays(list):
if player.lower() in list:
global humanPlay
global humanMove
humanPlay = possibleHumanPlays.index(list)
humanMove = possibleComputerPlays[humanPlay]
else:
global convertedFails
convertedFails += 1
convertPlays(rock)
convertPlays(paper)
convertPlays(scissors)
if convertedFails > 2:
print("Oops, you didn's seem to pick a possible move. Resetting")
continue
if humanMove == computerMove:
print("Tie!")
elif humanMove == "Rock" and computerMove == "Scissors" or humanMove == "Paper" and computerMove == "Rock" or humanMove == "Scissors" and computerMove == "Paper":
print("You Win!")
humanScore += 1
elif computerMove == "Rock" and humanMove == "Scissors" or computerMove == "Paper" and humanMove == "Rock" or computerMove == "Scissors" and humanMove == "Paper":
print("You Lose!")
computerScore += 1
print("You choose " + humanMove.lower() + " and The Computer choose " + computerMove.lower())
print("Your score is " + str(humanScore))
print("The Computer's score is " + str(computerScore))
again = input("Play again? ")
if yn(again):
continue
else:
break