-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrock_paper_scissors.py
More file actions
35 lines (22 loc) · 926 Bytes
/
rock_paper_scissors.py
File metadata and controls
35 lines (22 loc) · 926 Bytes
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
# IMPORTS
import random
import time
# SETUP
instructions = '''There will be three rounds. Rock is r, Paper is p, and Scissors are s.'''
options = ['r','p','s']
user_wins = 0
comp_wins = 0
def check_against(user):
comp_attempt = options[random.randrange(0,3)]
if user == 'r' and comp_attempt == 's' or user == 's' and comp_attempt == 'p' or user == 'p' and comp_attempt == 'r':
user_wins += 1
print('You won this round.')
elif comp_attempt == 'r' and user == 's' or comp_attempt == 's' and user == 'p' or comp_attempt == 'p' and user == 'r':
comp_wins += 1
print('you lost this round.')
print('You have won', user_wins, 'time(s). The computer has won', comp_wins,'time(s)')
return
print(instructions)
for x in range(3):
user_attempt = input('Enter either r,p, or s.\n- ').lower()
check_against(user_attempt)