-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRPS.py
More file actions
32 lines (28 loc) · 791 Bytes
/
RPS.py
File metadata and controls
32 lines (28 loc) · 791 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
__author__ = 'Christian'
import random
l = ["rock", "paper", "scissors"]
points = [0, 0]
def compare(u, c):
print(u + " <=> " + c)
if u == c:
print("Tie!")
return -1
elif (u == "rock" and c == "paper") or (u == "paper" and c == "scissors") or (u == "scissors" and c == "rock"):
print("Computer wins!")
return 1
else:
print("You win")
return 0
while True:
while True:
user = input("Do you choose rock, paper or scissors?").lower()
if user in l:
break
else:
print("Something went wrong")
comp = l[random.randint(0, 2)]
res = compare(user, comp)
if res != -1:
points[res] += 1
print("User: " + str(points[0]))
print("Computer: " + str(points[1]))