Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- def rps():
- user_wins = 0
- user_loses = 0
- user_ties = 0
- cont_choice = 1
- while (cont_choice != 0):
- comp_choice = int(random.randint(1,3))
- user_choice = int(input("Pick your weapon: Rock(1) Paper(2) Scissors(3) "))
- while(user_choice == 0 or user_choice > 3):
- print("Invalid selection. Try again.\n")
- user_choice = int(input("Pick your weapon: Rock(1) Paper(2) Scissors(3) "))
- if (user_choice == 0 or user_choice > 3):
- print("Invalid selection. Try again.")
- if (user_choice == 1 and comp_choice == 1):
- print("You both picked rock. Try again.")
- user_ties = user_ties + 1
- if (user_choice == 1 and comp_choice == 2):
- print("Paper covers rock, you lose.")
- user_loses = user_loses + 1
- if (user_choice == 1 and comp_choice == 3):
- print("Rock crushes scissors, you win.")
- user_wins = user_wins + 1
- if (user_choice == 2 and comp_choice == 1):
- print("Paper covers rock, you win.")
- user_wins = user_wins + 1
- if (user_choice == 2 and comp_choice == 2):
- print("You both picked paper. Try again.")
- user_ties = user_ties + 1
- if (user_choice == 2 and comp_choice == 3):
- print("Scissors cuts paper, you lose.")
- user_loses = user_loses + 1
- if (user_choice == 3 and comp_choice == 1):
- print("Rock crushes scissors, you lose.")
- user_loses = user_loses + 1
- if (user_choice == 3 and comp_choice == 2):
- print("Scissors cuts paper, you win.")
- user_wins = user_wins + 1
- if (user_choice == 3 and comp_choice == 3):
- print("You both picked scissors. Try again.")
- user_ties = user_ties + 1
- cont_choice = int(input("\nWould you like to continue? Yes(Any Number) No(0) "))
- print("\nTotal wins = " + str(user_wins) + "\n")
- print("Total loses = " + str(user_loses) + "\n")
- print("Total ties = " + str(user_ties) + "\n")
- rps()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement