[Level 2] Rock-Paper-Scissors
#!/bin/env python
import random
RPS = { 'Rock' : 1, 'Paper' : 2, 'Scissors' : 3 }
if __name__ == '__main__':
comRPS = random.choice(RPS.keys())
com = RPS[comRPS]
youRPS = raw_input('Rock/Paper/Scissors: ')
you = RPS[youRPS]
print 'Com: %s' % comRPS
print 'You: %s' % youRPS
if com % len(RPS.keys()) + 1 == you:
print 'You wins!'
elif you % len(RPS.keys()) + 1 == com:
print 'Com win!'
else:
print 'Break even!'
Wish this helps. regards,
Stanley Huang
Thankks for posting this
ReplyDelete