from random import choice class RPS: """Rock, paper, scissors""" win = {'r': 's', 's': 'p', 'p': 'r'} rps_word = {'r': 'rock', 'p': 'paper', 's': 'scissors'} def __init__(self, char=''): if char == '': self.value = choice('rps') else: self.value = char def __cmp__(self, other): if self.value == other.value: return 0 if self.win[self.value] == other.value: return 1 return -1 def __str__(self): return self.rps_word[self.value] if __name__ == '__main__': me = RPS() you = RPS(raw_input('Choose (r)ock, (p)aper or (s)cissors: ')) print 'Mine:', me print 'Yours:', you if you > me: print 'Congratulations! You win!' elif me > you: print 'I win!' else: print "Oh, it's a draw."