Rock-Paper-Scissors

Lesson 6 — Play the quick demo or build it in Python

In-Browser Demo

Click a choice to play against the computer.


Python Version

import random

choices = ['rock','paper','scissors']
player = input('Choose rock, paper, or scissors: ').lower()
computer = random.choice(choices)

print('Computer chose', computer)

if player == computer:
    print('Tie!')
elif (player == 'rock' and computer == 'scissors') or \
     (player == 'scissors' and computer == 'paper') or \
     (player == 'paper' and computer == 'rock'):
    print('You win!')
else:
    print('You lose!')