Rock Paper Scissors Lizzard Spock
November 23, 2020•320 words
Python bootcamp #100DaysOfCode #myNotes
Today was all about randomisation and Lists. At the end I had to build
the Rock Paper Scissors game. I added Lizzard and Spock too ;)
Your opponent is the computer.
The rules are:
- Scissors wins from Paper and Lizard
- Paper wins from Rock and Spock
- Lizard wins from Spock and paper
- Spock wins from Scissors and Rock
- Rock wins from Scissors and Lizard
#begin code
import random
user_input = int(
input(
"What do you choose? Type 0 for Rock, 1 for Paper,2 for Scissors, 3 for Lizard or 4 for Spock.\n"
))
computer_input = random.randint(0, 4)
rock = '''
_______
---' ____)
(_____)
(_____)
(____)
---.__(___)
'''
paper = '''
_______
---' ____)____
______)
_______)
_______)
---.__________)
'''
scissors = '''
_______
---' ____)____
______)
__________)
(____)
---.__(___)
'''
lizzard = '''
_.--._
.'()..()`.
.( `-.__.-' ).
. /
. /
'''
spock = '''
_
| |
___ _ __ ___ ___| | __
/ __| '_ . . _ . . __| |/ /
.__ . |_) | (_) | (__| <
|___/ .__/ .___/ .___|_| _.
| |
._.
'''
images = [rock, paper, scissors, lizzard, spock]
if user_input >= 5 or user_input < 0:
print("That's an invalid option.")
else:
print(images[user_input])
print("Computer chose:")
print(images[computer_input])
if (user_input == 0 and (computer_input == 2 or computer_input == 3)) or (
user_input == 1 and (computer_input == 0 or computer_input == 4)
) or (user_input == 2 and (computer_input == 1 or computer_input == 3)) or (
user_input == 3 and (computer_input == 1 or computer_input == 4)) or (
user_input == 4 and (computer_input == 0 or computer_input == 2)):
print("You win!")
elif user_input == computer_input:
print("It's a draw.")
else:
print("You lose.")
#end code