[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

Comments

Post a Comment

Popular posts from this blog

[Level 2] Shell Interactive With Zenity Episode 5 -- list

[Level 2] iif in Python