-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRock,paper,scissors game.py
More file actions
28 lines (27 loc) · 1008 Bytes
/
Rock,paper,scissors game.py
File metadata and controls
28 lines (27 loc) · 1008 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
import sys
user_1 =input("1st player's name :")
user_2 =input("2nd player's name :")
user1_answer = input("%s <<< do you want to choose (rock, paper and scissors) :>>>"%user_1)
user2_answer = input("%s <<< do you want to choose (rock, paper and scissors) :>>>"%user_2)
def campare(u1,u_1,u2,u_2):
if u1==u2:
return("game tie")
elif u1== 'rock':
if u2=='scissors':
return("%s >> (rock) wins"%u_1)
else:
return("%s >> (paper) wins"%u_2)
elif u1=='paper':
if u2=='rock':
return("%s >> (paper) wins"%u_1)
else:
return("%s >> (scissors) wins"%u_2)
elif u1=='scissors':
if u2=='paper':
return("%s >> (scissors) wins"%u_1)
else:
return("%s >> (rock) wins"%u_2)
else:
return("invalid input")
sys.exit()
print(campare(user1_answer,user_1,user2_answer,user_2))