Want more features on Pastebin? Sign Up, it's FREE!
Guest

hw_1, ex 1.7 rps.py

By: a guest on Dec 7th, 2012  |  syntax: Python  |  size: 1.57 KB  |  views: 47  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. player1input = raw_input("Player 1: Rock, Paper or Scissors?")
  2. if player1input == "Rock" or player1input == "rock" or player1input == "Paper"\
  3. or player1input == "paper" or player1input == "Scissors"\
  4. or player1input == "scissors":
  5.     player2input = raw_input("Player 2: Rock, Paper or Scissors?")
  6.     if player2input == "Rock" or player2input == "rock" or player2input == "Paper"\
  7.     or player2input == "paper" or player2input == "Scissors"\
  8.     or player2input == "scissors":
  9.         player1choice = player1input.lower() #in case input was upper or lowercase
  10.         player2choice = player2input.lower()
  11.         if player1choice == player2choice :
  12.             print "The result is a tie!"
  13.         elif player1choice == "rock" and player2choice == "paper" :
  14.             print "Paper beats Rock! Congratulations, Player 2!"
  15.         elif player1choice == "rock" and player2choice == "scissors" :
  16.             print "Rock beats Scissors! Congratulations, Player 1!"
  17.         elif player1choice == "paper" and player2choice == "rock" :
  18.             print "Paper beats Rock! Congratulations, Player 1!"
  19.         elif player1choice == "paper" and player2choice == "scissors" :
  20.             print "Scissors beats paper! Congratulations, Player 2!"
  21.         elif player1choice == "scissors" and player2choice == "rock" :
  22.             print "Rock beats Scissors! Congratulations, Player 2!"
  23.         else :
  24.             print "Scissors beats paper! Congratulations, Player 1!"
  25.     else :
  26.         print "This is not a valid object selection"
  27. else :
  28.     print "This is not a valid object selection”
clone this paste RAW Paste Data