-
Notifications
You must be signed in to change notification settings - Fork 43
/
Rock-Paper-Scissors.py
36 lines (35 loc) · 1.34 KB
/
Rock-Paper-Scissors.py
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
#import library
import random
#array
com = ["Rock", "Paper", "Scissors"]
#algorithm for playing
def battle(player1,player2):
if player1.lower() == player2.lower(): #.lower to read into lower case
print ("Computer: "+ player2) #to show what computer get from random choice
print ("Draw!")
elif player1.lower() == "Rock".lower() and player2 == "Paper":
print ("Computer: "+ player2)
print ("You Lose!")
elif player1.lower() == "Rock".lower() and player2 == "Scissors":
print ("Computer: "+ player2)
print ("You Win!")
elif player1.lower() == "Paper".lower() and player2 == "Rock":
print ("Computer: "+ player2)
print ("You Win!")
elif player1.lower() == "Paper".lower() and player2 == "Scissors":
print ("Computer: "+ player2)
print ("You Lose!")
elif player1.lower() == "Scissors".lower() and player2== "Rock":
print ("Computer: "+ player2)
print ("You Lose!")
elif player1.lower() == "Scissors".lower() and player2== "Paper":
print ("Computer: "+ player2)
print ("You Win!")
else:
print ("===TYPO===") #to show when you typo
#run it
run = True
while run:
player1 = input("Input Your Choice\nYou: ") #to input your choice
player2 = random.choice(com) #random choice
battle(player1,player2) #show the function