DEV Community

Cover image for My #100daysOfCode Challenge - Python 100 projects in 100 days - Journal Entries - Day 4
Anthony Beckford🚀
Anthony Beckford🚀

Posted on

My #100daysOfCode Challenge - Python 100 projects in 100 days - Journal Entries - Day 4

Day 4 - Rock, Paper, Scissors game

import random

rock = '''
_______
---' _)
(
)
(
)
(
)
---.
(__)
'''

paper = '''
_______
---' _)_
___)
_
)
_
)
---.
_______)
'''

scissors = '''
_______
---' _)_
___)
_
___)
(
)
---.
(__)
'''
game_image = [rock, paper, scissors]

user_choice = int(input("What do you choose? Type 0 for Rock, 1 for Paper or 2 for Scissors.\n"))
print(game_image[user_choice])

computer_choice = random.randint(0, 2)
print("computer chose:")
print(game_image[computer_choice])

if user_choice >= 3 or user_choice < 0:
print("You typed an invalid number, you lose!")
elif user_choice == 0 and computer_choice == 2:
print('You Win!')
elif computer_choice == 0 and user_choice == 2:
print("You Lose!")
elif computer_choice > user_choice:
print("You Lose!")
elif user_choice > computer_choice:
print("You Win!")
elif computer_choice == user_choice:
print("Draw game!")

Key Takeaways:

  1. Learned about Randomisation adn Python List

Top comments (0)