Skip to content

Commit a945e9d

Browse files
authored
Rock, Paper & Scissor.py (#8)
1 parent 7d080c6 commit a945e9d

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

Rock, Paper & Scissor.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import random
2+
3+
rock = '''
4+
_______
5+
---' ____)
6+
(_____)
7+
(_____)
8+
(____)
9+
---.__(___)
10+
'''
11+
12+
paper = '''
13+
_______
14+
---' ____)____
15+
______)
16+
_______)
17+
_______)
18+
---.__________)
19+
'''
20+
21+
scissors = '''
22+
_______
23+
---' ____)____
24+
______)
25+
__________)
26+
(____)
27+
---.__(___)
28+
'''
29+
game_images = [rock, paper, scissors]
30+
31+
user_choice = int(input("What do you choose? Type 0 for Rock, 1 for Paper or 2 for Scissors.\n"))
32+
if user_choice >= 3 or user_choice < 0:
33+
print("You typed an invalid number, you lose!")
34+
else:
35+
print(game_images[user_choice])
36+
37+
computer_choice = random.randint(0, 2)
38+
print("Computer chose:")
39+
print(game_images[computer_choice])
40+
41+
42+
if user_choice == 0 and computer_choice == 2:
43+
print("You win!\n")
44+
elif computer_choice == 0 and user_choice == 2:
45+
print("You lose\n")
46+
elif computer_choice > user_choice:
47+
print("You lose\n")
48+
elif user_choice > computer_choice:
49+
print("You win!\n")
50+
elif computer_choice == user_choice:
51+
print("It's a draw\n")

0 commit comments

Comments
 (0)