Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- score1 = 0
- score2 = 0
- def main():
- while True:
- player = input('What do you choose to play (R, P, S)? ')
- computer = random.choice(["R", "P", "S"])
- print("You chose", (player), "and the computer chose", (computer))
- if computer == player:
- print("It's a tie")
- print("Score: You =", score1, "Computer =", score2)
- if computer == "R" and player == "S":
- print("Computer wins")
- print("Score: You =", score1, "Computer =", score2 + 1)
- if computer == "P" and player == "R":
- print("Computer wins")
- print("Score: You =", score1, "Computer =", score2 + 1)
- if computer == "S" and player == "P":
- print("Computer wins")
- print("Score: You =", score1, "Computer =", score2 + 1)
- if computer == "S" and player == "R":
- print("You won")
- print("Score: You =", score1 + 1, "Computer =", score2)
- if computer == "R" and player == "P":
- print("You won")
- print("Score: You =", score1 + 1, "Computer =", score2)
- if computer == "P" and player == "S":
- print("You won")
- print("Score: You =", score1 + 1, "Computer =", score2)
- play_again = input("Would you like to play again? Y/N ")
- if play_again == "Y":
- main()
- if play_again == "y":
- main()
- if play_again == "Yes":
- main()
- if play_again == "yes":
- main()
- else:
- print("You scored", score1, "and the computer scored", score2)
- exit()
- main()
Advertisement
Add Comment
Please, Sign In to add comment