51 lines
No EOL
1 KiB
Python
51 lines
No EOL
1 KiB
Python
import random
|
|
import sys
|
|
|
|
rock = """
|
|
_______
|
|
---' ____)
|
|
(_____)
|
|
(_____)
|
|
(____)
|
|
---.__(___)
|
|
"""
|
|
|
|
paper = """
|
|
_______
|
|
---' ____)____
|
|
______)
|
|
_______)
|
|
_______)
|
|
---.__________)
|
|
"""
|
|
|
|
scissors = """
|
|
_______
|
|
---' ____)____
|
|
______)
|
|
__________)
|
|
(____)
|
|
---.__(___)
|
|
"""
|
|
|
|
|
|
hands = [rock, paper, scissors]
|
|
com_choice = random.randint(0, 2)
|
|
|
|
try:
|
|
p1_choice = int(input("whats your choice? 0=rock, 1=paper, 2=scissors: "))
|
|
except ValueError as e:
|
|
print(f"Conversion failed: {e}")
|
|
sys.exit(1)
|
|
|
|
if (p1_choice < 0 or p1_choice > 2):
|
|
print("Must be 0, 1 or 2")
|
|
sys.exit(1)
|
|
elif (p1_choice == com_choice):
|
|
print ("It's Draw!")
|
|
elif (p1_choice == 2 and com_choice == 0) or (p1_choice == 0 and com_choice == 1) or (p1_choice == 1 and com_choice == 2) :
|
|
print ("COM WON!")
|
|
elif (p1_choice == 0 and com_choice == 2) or (p1_choice == 1 and com_choice == 0) or (p1_choice == 2 and com_choice == 1) :
|
|
print ("P1 WON!")
|
|
|
|
print(hands[p1_choice], hands[com_choice]) |