Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #how the computer chooses their play
- import random
- comp = random.randint(1,3)
- #Ask the user to play
- def intro():
- print("Welcome to Rock, Paper, Scissor! Please choose your weapon:")
- print("1. Rock")
- print("2. Paper")
- print("3. Scissor")
- intro()
- #Ask them if they want to play again - look in game()
- def again():
- print("Do you want to play again?(Y/N)")
- play = input()
- play = play.lower()
- if play == "y" or play == "yes":
- intro()
- game()
- elif play == "n" or play == "no" :
- print("Bye")
- else:
- print("Please type either Y or N")
- again()
- #results
- compw = "==> Computer wins!"
- userw = "==> User wins!"
- draw = "==> Draw!"
- #The actual game
- def game():
- print("", end='\n\n')
- print("Your weapon: ", end="")
- user = input()
- user = user.lower()
- choice = ["rock","paper","scissor"]#the player's set of choice
- #check the user's input
- if user.isalpha() == True and user in choice:
- print("You have chosen",user,"!")
- #Computer choose rock
- if comp == 1:
- print("Computer chose rock!")
- if user == "rock":
- print("Rock VS Rock", end='\n\n')
- print(draw)
- if user == "paper":
- print("Rock VS Paper", end='\n\n')
- print(userw)
- if user == "scissor":
- print("Rock VS Scissor", end='\n\n')
- print(compw)
- again()
- #Computer choose paper
- elif comp == 2:
- print("Computer chose paper!")
- if user == "rock":
- print("Paper VS Rock", end='\n\n')
- print(compw)
- if user == "paper":
- print("Rock VS Paper", end='\n\n')
- print(draw)
- if user == "scissor":
- print("Rock VS Scissor", end='\n\n')
- print(userw)
- again()
- #Computer choose scissor
- elif comp == 3:
- print("Computer chose scissor!")
- if user == "rock":
- print("Scissor VS Rock", end='\n\n')
- print(userw)
- if user == "paper":
- print("Scissor VS Paper", end='\n\n')
- print(compw)
- if user == "scissor":
- print("Scissor VS Scissor", end='\n\n')
- print(draw)
- again()
- else: #for when they input incorrectly
- print("Invalid input. Please type one of these words: Rock, Paper, Scissor")
- game()
- game()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement