Rock-paper-scissors: Difference between revisions

Content added Content deleted
Line 3,347: Line 3,347:
choose your weapon: rock
choose your weapon: rock
the computer played paper; the computer beat you... :(</pre>
the computer played paper; the computer beat you... :(</pre>

This is another code. Output is as same as the above output.
<lang python>from random import randint

hands = ['rock', 'scissors', 'paper']; judge = ['its a tie!', 'the computer beat you... :(', 'yay you win!']
while True:
try:
YOU = hands.index(input('Choose your weapon: ')) # YOU = hands.index(raw_input('Choose your weapon: ')) If you use Python2.7
except ValueError:
break
NPC = randint(0, 2)
print('The computer played ' + hands[NPC] + '; ' + judge[YOU-NPC])</lang>


=={{header|Rascal}}==
=={{header|Rascal}}==