Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 6 additions & 15 deletions Rock,paper,scissors.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,15 @@
import random
chars = "RPS"
def rps(User,computer):
if User== "R" and computer== "P":
return "computer won!!"
elif User == "P" and computer == "R":
return "You won!!"
elif User == "P" and computer == "S":
return "computer won!!"
elif User == "S" and computer == "P":
return "You won!!"
elif User == "R" and computer == "S":
return "You won!!"
elif User == "S" and computer == "P":
return "computer won!!"
elif User not in chars:
if User not in chars:
return "wrong input"
elif User == computer:
return "tie"
run = True
return "You won" if (User== "S" and computer== "P") or (User == "P" and computer == "R") or (User == "R" and computer == "S") else "Computer Won"
run = 3
while run:
User = input("R for rock ,P for Paper,S for scissors : \n")
run -= 1
User = input("R for rock ,P for Paper,S for scissors : \nYour Choice: ").upper()
computer = random.choice(chars)
print("Computer's choice",computer)
print(rps(User,computer))