Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from random import randint
- #pc choice
- def get_computer_hand():
- r=randint(1,3)
- if r == 1:
- hand = "rock"
- elif r == 2 :
- hand = "paper"
- elif r == 3 :
- hand = "scissor"
- return hand
- # men el kseb
- def whowin(you,comp):
- if you == comp:
- winner = "tie"
- elif (comp == "rock" and you == "scissor") or (comp == "scissor" and you == "paper") or (comp == "paper" and you == "rock"):
- winner = "comp"
- else:
- winner = "you"
- return winner
- # start
- def play():
- print "------welcome to my game------"
- comp_wins = 0
- you_wins = 0
- tie_wins = 0
- while True:
- you = raw_input("Please choose rock or scissor or paper ")
- you=you.lower()
- if not you == "rock" or you == "paper" or you == "scissor" :
- print" you choosed wrong answer"
- continue
- comp = get_computer_hand()
- winner = whowin(you,comp)
- play()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement