-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRock Paper Scissors.py
More file actions
40 lines (40 loc) · 1.39 KB
/
Copy pathRock Paper Scissors.py
File metadata and controls
40 lines (40 loc) · 1.39 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
import random
options = ["rock", "paper","scissors"]
computer_score = 0
user_score = 0
while True:
user_input = input("Enter rock/paper/scissors or Q to quit. ").lower()
if user_input == "q":
break
elif user_input not in options:
print('Pkease enter a valid input.')
continue
rand_num = random.randint(0, 2)
computer_input = options[rand_num]
if user_input == "rock" and computer_input == "scissors":
print("Computer's pick is", computer_input)
print("You Won!")
user_score += 1
elif user_input == "paper" and computer_input == "rock":
print("Computer's pick is", computer_input)
print('You won!')
user_score += 1
elif user_input == "scisssor" and computer_input == "paper":
print("Computer's pick is", computer_input)
print('You won!')
user_score += 1
elif user_input==computer_input:
print("The computer's pick is :", computer_input)
print("Tie!!")
else:
print("Computer's pick is", computer_input)
print('You lost!')
computer_score += 1
print('Your score =', user_score)
print("Computer's score =", computer_score)
if user_score>computer_score:
print('Congratulations! You Have Won The Game!')
elif user_score==computer_score:
print('The Game Is A Tie!')
else:
print('Sorry, You Lost The Game!')