-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathrockPaperScissors.py
More file actions
75 lines (70 loc) · 1.53 KB
/
Copy pathrockPaperScissors.py
File metadata and controls
75 lines (70 loc) · 1.53 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
63
64
65
66
67
68
69
70
71
72
73
74
75
from os import system, name
def clear():
'''Library Way to Clear Screen'''
if name == 'nt':
_ = system("cls")
else:
_ = system("clear")
# ascii art for rock, paper, scissors
symbols = [
'''
_______
---' ____)
(_____)
(_____)
(____)
---.__(___)
'''
,
'''
_______
---' ____)____
______)
_______)
_______)
---.__________)
'''
,
''' _______
---' ____)____
______)
__________)
(____)
---.__(___)
'''
]
# import the random module
import random
def rock_paper_scissors():
'''Rock Paper Scissors Game'''
#prompt the player to choose
try:
playerMove = int(input("What do you choose? Type 0 for Rock, 1 for Paper, or 2 for Scissors.\n"))
except ValueError:
print("Value Error")
input("Press enter to continue...")
clear()
rock_paper_scissors()
else:
# check if the player move is in range
if playerMove<0 or playerMove>2:
print("Wrong input! You lose!")
else:
# print the player's move
print(symbols[playerMove])
print("Computer chose:")
computerMove = random.randint(0,2)
print(symbols[computerMove])
if playerMove==computerMove:
print("It's a draw!")
elif playerMove>computerMove or computerMove-playerMove==2:
print("You Win!")
else:
print("You Lose!")
# 0>2, 0<1
# 1>0, 1<2
# 2>1, 2<0
if input("Type y to play again: ") == 'y':
clear()
rock_paper_scissors()
rock_paper_scissors()