Rock Paper and Scissor game in python
from random import randint
print("{:*^50}".format("Welcome in game"))
print()
l=["rock","paper","scissor"]
def game(n):
s=randint(0,2)
print("computer chooses-",l[s])
if n==l[s]:
print ("it's a tie")
print ()
elif (n=="rock" and l[s]=="scissor")or\
(n=="paper" and l[s]=="rock")or\
(n=="scissor" and l[s]=="paper"):
print("congrats you won! ")
print ()
else:
print("you lose it! ")
print()
while True:
n=str(input(" Rock, Paper or Scissor-"))
if n!="quit":
game (n)
else:
break
Example-
Output-
Rock, Paper or Scissor- rock
computer chooses-scissor
congrats you won!
Rock, Paper or Scissor-quit
Game over
Comments
Post a Comment
If you have any doubt you ask me in comment section