#Step 2: implement the random
comp = random.randrange(1,4)
user = random.randrange(1,4)
#Step 3: assigning the integer to Rock, Scissor and Paper before the next block
if comp == 1:
comp = 'paper'
elif comp == 2:
comp = 'rock'
elif comp == 3:
comp = 'scissor'
if user == 1:
user = 'paper'
elif user == 2:
user = 'rock'
elif user == 3:
user = 'rock'
print "Computer choose: ",comp
print "User choose: ", user
print ""
#Step 1: build the main logic of the RSP
"""4 possibilities, if comp is rock, how user win the game and so on"""
if comp == user:
print 'Tie !!!'
elif comp == 'rock':
if user == 'paper':
print 'User win !'
else:
print 'Computer win !'
elif comp == 'paper':
if user == 'scissor':
print 'User win !'
else:
print 'Computer win !'
elif comp == 'scissor':
if user == 'rock':
print 'User win !'
else:
print 'Computer win !'
Output
Computer choose: rock User choose: rock Tie !!!