All pastes #729656 Raw Edit

RPS

public python v1 · immutable
·published 2007-10-08 05:33 UTC
rendered paste body
import randomlook = { 0: 'Rock', 1: 'Paper', 2: 'Scissors' }revlook = { 'r': 0, 'p': 1, 's': 2 }while True:  compChoice = random.randint(0,2)  userChoice = revlook[raw_input('Enter your choice: ').lower()]  print 'You picked %s and the computer picked %s.\n' % ( look[userChoice], look[compChoice] )  if compChoice - userChoice == 0:    print 'Tie!'    continue  if compChoice == ( userChoice - 1 ) % 3: print 'You win!'  if compChoice != ( userChoice - 1 ) % 3: print 'Computer wins!'