Rock, paper, Scissors (python 3.3) - python

Hi i'm making a rock paper scissors game and i have made the following script so far:
def main():
from random import randint
UserChoices = input("'rock', 'paper' or 'scissors'? \n Input: ")
if UserChoices == "rock":
UserChoice = 1
elif UserChoices == "paper":
UserChoice = 2
elif UserChoices == "scissors":
UserChoice = 3
CpuChoice = randint(1,3)
if UserChoice == CpuChoice:
print("DRAW!")
elif UserChoice == "1" and CpuChoice== "3":
print("Rock beats scissors PLAYER WINS!")
main()
elif UserChoice == "3" and CpuChoice== "1":
print("Rock beats scissors CPU WINS")
main()
elif UserChoice == "1" and CpuChoice== "2":
print("Paper beats rock CPU WINS!")
main()
elif UserChoice == "2" and CpuChoice== "1":
print("paper beats rock PLAYER WINS!")
main()
elif UserChoice == "2" and CpuChoice== "3":
print("Scissors beats paper CPU WINS!")
main()
elif UserChoice == "3" and CpuChoice== "2":
print("Scissors beats paper PLAYER WINS!")
main()
elif UserChoice == "1" and CpuChoice== "2":
print("cpu wins")
main()
else:
print("Error: outcome not implemented")
main()
but when I run it I get the error I made "Error: outcome not implemented" Can someone tell me why this is? thank you.

This and all the other comparisons similar to it:
elif UserChoice == "1" and CpuChoice == "3":
... should be:
elif UserChoice == 1 and CpuChoice == 3:
In other words, you should be comparing ints with ints, instead of ints with strings as is happening right now.

User choice is set to an integer, however you compare it to a string. It should be as follows
if userChoice == 1: #Note no quotation marks
Also, you are allowing the CPU to choose from 3 integers, which works. However, it may save lines and be more efficient to choose a random from an array
CPU_Moves = ['Rock','Paper','Scissors']
cpuchoice = random.choice(CPUMoves)
This will set cpuchoice to one of the random from the array, and you can then use it in the comparison of user input to the cpuchoice. This would mean you wouldn't need to set userChoice at all, you could use what the user enters directly.

As the previous answers say, you ended up comparing a string against an integer.
It would be a good idea to avoid using so many conditionals. Here's a "compact version" I've written, in case you're interested:
from random import randrange
def RPS(user_choice = ''):
choices = ('rock', 'paper', 'scissors')
results = ('Draw!', 'You Win!', 'Cpu Wins!')
while user_choice not in choices:
user_choice = input("Choose: rock, paper or scissors? ")
user_num = choices.index(user_choice)
cpu_num = randrange(3)
diff = (user_num - cpu_num) % 3
print("You chose:", user_choice, "-", "Cpu chose:", choices[cpu_num])
print(results[diff])
RPS('rock') # User choice can be passed as an argument.
Notice how you can calculate the winner with a subtraction and a modulo operation. This is even more useful in a Rock, paper, scissors, lizzard, Spock game, where you have 5 choices instead of 3.

remove the quotes from your if else statement. the conditionals are looking for a string to compare while rock paper and scissors are assigned as integers. these are not handled the same way. you need to change your if elif to not have quotes around the numbers. it prints out DRAW because its comparing like items and it give and error because it is not the same variable type.

Related

Why am I not getting the correct outputs for my game?

I am very new to Python and coding in general. I tried to create my own Rock, Paper, Scissors game. The issue I'm getting can be tested by doing the following: typing "rock", then typing "yes" to play again and repeating those two steps. Eventually, it gives me an "Invalid Input." It is only supposed to print this if the user types something besides rock, paper, or scissors. Is there any way I can fix this? I'd really appreciate any input and advice. Thank you for your time.
import random
# to loop the program
def Repeat():
Answer = input ("Do you want to play again? (Y/N): ")
if Answer == ("Yes") or Answer == ("yes") or Answer == ("Y") or Answer == ("y"):
Game()
if Answer == ("No") or Answer == ("no") or Answer == ("N") or Answer == ("n"):
exit()
else:
print ("Invalid Input")
Repeat()
def Game():
# Variable Reset
Choice = None
Opponent_Choice = None
# Choices
Opponent_Choices = ["Rock", "Paper", "Scissors"]
Choice = input ("Type Rock, Paper, or Scissors: ")
Opponent_Choice = random.choice(Opponent_Choices)
# Outcomes
# if you choose rock
if Choice == "Rock" or Choice == "rock":
if Opponent_Choice == "Paper":
print ("your opponent chose Paper. You lose!")
Repeat()
elif Opponent_Choice == "Scissors":
print ("your opponent chose Scissors. You win!")
Repeat()
elif Opponent_Choice == "Paper":
print ("your opponnent chose Rock. It was a tie!")
Repeat()
# if you choose paper
elif Choice == "Paper" or Choice == "paper":
if Opponent_Choice == "Paper":
print ("your opponent chose Paper. It was a tie!")
Repeat()
elif Opponent_Choice == "Scissors":
print ("your opponent chose Scissors. You lose!")
Repeat()
elif Opponent_Choice == "Paper":
print ("your opponent chose Rock. You win!")
Repeat()
# if you choose scissors
elif Choice == "Scissors" or Choice == "scissors":
if Opponent_Choice == "Paper":
print ("your opponent chose Paper. You win!")
Repeat()
elif Opponent_Choice == "Scissors":
print ("your opponent chose Scissors. It was a tie!")
Repeat()
elif Opponent_Choice == "Paper":
print ("your opponet chose Rock. You lose!")
Repeat()
else:
print ("Invalid input")
Game()
Game()
p.s. Sorry for the messy code :P Still very new to this.
The actual issue:
The actual issue
The reason you seem to be getting the invalid input is due to your check for the Opponent_choice not checking for Rock but instead checking for paper twice. Therefore it jumps all the way to the else statement at the end of the function which contains the invalid input print statement if the opponent chooses Rock.
if Opponent_Choice == "Paper":
print ("your opponent chose Paper. You lose!")
Repeat()
elif Opponent_Choice == "Scissors":
print ("your opponent chose Sciccors. You win!")
Repeat()
elif Opponent_Choice == "Paper": #error here
print ("your opponnet chose Rock. It was a tie!")
Repeat()
The fix would be
if Opponent_Choice == "Paper":
print ("your opponent chose Paper. You lose!")
Repeat()
elif Opponent_Choice == "Scissors":
print ("your opponent chose Sciccors. You win!")
Repeat()
elif Opponent_Choice == "Rock": #change made here
print ("your opponnet chose Rock. It was a tie!")
Repeat()
One problem with the code is that you have functions calling themselves.
The function Game() and Repeat() in your code do this. This is called recursion and can be very useful. But it can also cause problems if used incorrectly. For one thing, let's consider the code above DOES work, if you played it for very long, you would get a stack overflow exception. I would suggest some research on recursion and "the stack" to understand this better.
If you take out the recursion like so for example:
it should work.
I also noticed you are checking user input on the confirmation question. Very nice. But why not for the Rock Paper Scissors selection?
Example refactor without recursion:
import random
# to loop the program
def Repeat():
while True:
result = Confirm()
if (result is True):
break
def Confirm():
Answer = input ("Do you want to play again? (Y/N): ")
if Answer == ("Yes") or Answer == ("yes") or Answer == ("Y") or Answer == ("y"):
return True
if Answer == ("No") or Answer == ("no") or Answer == ("N") or Answer == ("n"):
exit()
else:
return False
def Game():
# Choices
Opponent_Choices = ["Rock", "Paper", "Scissors"]
Choice = input("Type Rock, Paper, or Scissors: ")
Opponent_Choice = random.choice(Opponent_Choices)
# Outcomes
# if you choose rock
if Choice == "Rock" or Choice == "rock":
if Opponent_Choice == "Paper":
print ("your opponent chose Paper. You lose!")
Repeat()
elif Opponent_Choice == "Scissors":
print ("your opponent chose Sciccors. You win!")
Repeat()
elif Opponent_Choice == "Paper":
print ("your opponnet chose Rock. It was a tie!")
Repeat()
# if you choose paper
elif Choice == "Paper" or Choice == "paper":
if Opponent_Choice == "Paper":
print ("your opponent chose Paper. It was a tie!")
Repeat()
elif Opponent_Choice == "Scissors":
print ("your opponent chose Sciccors. You lose!")
Repeat()
elif Opponent_Choice == "Paper":
print ("your opponet chose Rock. You win!")
Repeat()
# if you choose scissors
elif Choice == "Scissors" or Choice == "scissors":
if Opponent_Choice == "Paper":
print ("your opponent chose Paper. You win!")
Repeat()
elif Opponent_Choice == "Scissors":
print ("your opponent chose Sciccors. It was a tie!")
Repeat()
elif Opponent_Choice == "Paper":
print ("your opponet chose Rock. You lose!")
Repeat()
else:
print ("Invalid input")
while True:
Game()
I can't give you an answer about why there's an error, but here is a clue: the 'invalid input' message you get was from line 11, in Repeat(). The line will only be run if the if statement above it evaluates to false, and the if statement will only be run if the other if statement above it exits, which means you'll only get the message if the Game()-function somehow exited, which shouldn't happen. You can add a print()-statement after line 7 to confirm that. The REAL reason was because you used recursion, like #dominic has said. And you should try their code.
PS: don't feel bad about messy code. Mine is worse than yours. But you really don't have to capitalize the variables and function. Good luck with Python!

Why is a random result for the code being displayed?

main.py:
import functions
def main():
count = True
while count == True:
print("Enter R for Rock")
print("Enter P for Paper")
print("Enter S for Scissors")
value = input("Choose from R/P/S: ") # taking input from the user, they can tpye R/P/S or r/p/s to play a game. Rock Paper Scissors
if value == "R" or value =="r":
print()
print(functions.rock(value))
elif value == "P" or value =="p":
print()
print(functions.paper(value))
elif value == "S" or value =="s":
print()
print(functions.scissors(value))
#Using If statement so if the user input is "R" then it will call the rock fucntion, if its "P" it will call the paper function and if its "S" it will call the scissors function.
else:
print()
print("Invalid Input, Please enter R for Rock, P for Paper, S for Scissors")
# if there's an invalid input the program will stop and redirect them to the correct input process
break
print("------------")
main()
function.py:
import random
def computer_choice():
choice = random.randint(1, 3)
if choice == 1:
return "Rock"
elif choice == 2:
return "Paper"
elif choice == 3:
return "Scissors"
# getting a random string from a,b,c variable. The random variable will be the computers input
def rock(value):
print("Computer choice:", computer_choice())
print()
if computer_choice() == "Rock":
return("Its a draw")
elif computer_choice() == "Paper":
return("The computer wins")
else:
return("You Win")
def paper(value):
print("Computer choice:", computer_choice())
print()
if computer_choice() == "Rock":
return("You Win")
elif computer_choice() == "Paper" :
return("Its a draw")
else:
return("The computer wins")
def scissors(value):
print("Computer choice:", computer_choice())
print()
if computer_choice() == "Rock":
return("The computer wins")
elif computer_choice() == "Paper":
return("You win")
else:
return("Its a draw")
# defining all the functions and giving each function a decision structure and the pattern for rock paper scissors.
Why is a random result for the code being displayed? The only thing random was supposed to be the choice of the computer but the results are random too The code seems to send random results from the functions where I used the random function. The "function.py" returns a random result and not the one that was supposed to be send
Every time you use computer_choice() in an if statement it is generating a new random choice because you are calling the function. Instead you want to make a variable and assign computer_choice() to it, then refer to this variable in your if statements.
For example rock would become:
def rock(value):
comp = computer_choice()
print("Computer choice:", comp)
print()
if comp == "Rock":
return("Its a draw")
elif comp == "Paper":
return("The computer wins")
else:
return("You Win")

Why does the if statements in my program not function when it's put in a function that's meant to run?

I have created a rock, paper scissors game in Python, posted it on replit, and now the 'if statements' refuse to function.
print("Welcome to the official game of Rock, Paper, Scissors!")
option = input('''Pick an option: Rock, Paper, Scissors
>>> ''').lower()
import random
game_op =["rock", "paper", "scissors"]
computer_option = print(random.choice(game_op))
def options():
if option == "rock" and computer_option == "rock":
print("You and the Computer chose the same options.")
print('The end')
elif option == "rock" and computer_option == "paper":
print("The Computer wins!")
print('The end')
elif option == "rock" and computer_option == "scissors":
print("You win!")
print('The end')
elif option == "paper" and computer_option == "rock":
print("You win!")
print('The end')
elif option == "paper" and computer_option == "paper":
print("You and the Computer chose the same options.")
print('The end')
elif option == "paper" and computer_option == "scissors":
print("The Computer wins!")
print('The end')
elif option == "scissors" and computer_option == "rock":
print("The Computer wins!")
print('The end')
elif option == "scissors" and computer_option == "scissors":
print("You and the Computer chose the same options.")
print('The end')
elif option == "scissors" and computer_option == "paper":
print("You win!")
print('The end')`enter code here`
print(options())
I tried making a function to handle the if statements and when you and the computer have decided on your move, the function works, but all its printing is 'None'.
In your code, you have the line option.lower. This does not call any function nor does it reassign option to anything. Thus, if the user inputs "ROCK", all the if and elif clauses will be ignored. Rewrite the first few lines to:
print("Welcome to the official game of Rock, Paper, Scissors!")
option = input('''Pick an option: Rock, Paper, Scissors
>>> ''').lower()
Note that inputting something like "banana" will still cause all of the if and elif clauses to be ignored.

How to make a helper function work - please see code below

I'm trying to make a rock, paper, and scissors game that receives input from a user that plays against a robot that randomly selects rock, paper, or scissors. Here is my main() code:
"""
Name: Scott Houston
Date: January 19th, 2021
Program Description: Game of classic rock, paps
"""
import random
import gameFunctions2
def main():
while True:
computer_move = random.randint(1, 3)
print("Welcome to rock, paper, scissors! Rock beats scissors, scissors beats paper,"
" and paper beats rock. ")
user_input = input("Press 'A' for rock, 'B' for paper, and 'C' for scissors!\n"
"A. Rock\n"
"B. Paper\n"
"C. Scissors\n")
if gameFunctions2.tie(user_input, computer_move) == False:
if user_input == "A" or user_input == "a":
if computer_move == 2:
print("Your opponent has chosen paper! Paper wraps rock! You lose! ")
else:
print("Your opponent has chosen scissors! Rock breaks scissors! You win! ")
elif user_input == "B" or user_input == "b":
if computer_move == 3:
print("Your opponent has chosen scissors! Paper is cut by scissors! You lose! ")
else:
print("Your opponent has chosen rock! Paper wraps rock! You win! ")
elif user_input == "C" or user_input == "c":
if computer_move == 1:
print("Your opponent has chosen rock! Scissors loses to rock! You lose! ")
else:
print("Your opponent has chosen paper! Scissors beats paper! You win! ")
if gameFunctions2.input_detection(user_input) == True:
print()
else:
print()
user_play_again = input("Would you like to play again? Type 'y' if you'd like to play again. ")
if user_play_again == "y":
print()
else:
print("Have a great day! ")
break
# Calls the Main Function
main()
Here is my helper function (gameFunctions2):
def input_detection(user_input):
if user_input == "A" or user_input == "a" or user_input == "B" or user_input == "b" or user_input == "C" or user_input == "c":
return True
else:
print("Please enter a valid option! ")
return False
def tie(user_input, computer_move):
if user_input == user_input.lower in ["a"] and computer_move == "1":
print("It's a tie!")
return True
if user_input == user_input.lower in ["b"] and computer_move == "2":
print("It's a tie!")
return True
if user_input == user_input.lower in ["c"] and computer_move == "3":
print("It's a tie!")
return True
else:
return False
The problem that I'm facing right now is that there will never be a tie between the user and the computer. I've tried to implement the function tie(user_input, computer_move) into main(), but to no success. I have to use helper functions for this assignment, so I'm trying my best to do so. Also, if there's any place that I can make my code more efficient, it would be fantastic if you could point out where :))
Change your tie function to this:
def tie(user_input, computer_move):
if user_input.lower() == "a" and computer_move == 1:
print("It's a tie!")
return True
elif user_input.lower() == "b" and computer_move == 2:
print("It's a tie!")
return True
elif user_input.lower() == "c" and computer_move == 3:
print("It's a tie!")
return True
else:
return False
You cant compare String and Int like this: computer_move == "1" when computer_move is Int.
Simplify the user_input.lower() == "a" statement.
Here is what you can use to make your code more readable:
Use dictionary to translate users input into integers.
Then you can also easily check all the conditions.
Here is the code (I have only added the part where I have get rid of the tie function):
import random
choose = "Start"
symbols = {"rock":1, "paper":2, "scissors":3}
while True:
choose = input("Hi welcome to my game! Choose between Rock, Paper, Scissors! End the game with 'End':\n")
choose = choose.lower()
computer = random.randint(1,3)
if choose in symbols: #Check if input is in a string and if its in symbols
choose = symbols[choose]
elif choose == "end":
break
else:
print("You have written down something ... weird ... next round.")
continue
if choose == computer:
print("It's a tie!")
else:
#Choose who wins ...
pass
There are a lot of minor issues in your code that can be streamlined and a few major ones, but the one causing your issues is that you are defining computer_move as an integer in the main function (computer_move = random.randint(1, 3)), but in your tie function, you are comparing it to a string (eg, computer_move == "1") The first half of your if statement also is not doing what you want: Rewrite that function as such:
def tie(user_input, computer_move):
if user_input.lower() == "a" and computer_move == 1:
print("It's a tie!")
return True
if user_input.lower() == "b" and computer_move == 2:
print("It's a tie!")
return True
if user_input() == "c" and computer_move == 3:
print("It's a tie!")
return True
else:
return False
If you don't want to have a different if statement for each possible outcome, you can try this:
def outcomes(user_input, computer_move):
end_states = {"tie": [["a", 1], ["b",2], ["c",3]],
"user_win": ["LISTS OF USER WIN STATES"]}
if [user_input.lower(), computer_move] in end_states["tie"]:
print("tie")
if [user_input.lower(), computer_move] in end_states["user_win"]:
print("user wins")
else:
print("computer wins")
A few of the fixes:
user_input = input("Press 'A' for rock, 'B' for paper, and 'C' for scissors!\n"
"A. Rock\n"
"B. Paper\n"
C. Scissors\n")
can be changed to:
user_input = input("Press 'A' for rock, 'B' for paper, and 'C' for scissors!\n"
"A. Rock\n"
"B. Paper\n"
C. Scissors\n").lower()
so that you don't need to check for both upper and lower cases each time (you would also be able to remove .lower() from the tie function.
You should move the input_detection function to right after the user makes the input, and you can rewrite the check as such:
if not gameFunctions2.input_detection(user_input):
continue
Which roughly translates to, if it returns "False", return to the start of your while loop (You can also remove the checks for uppercase and lowercase letters, if you use the previous edit).
For checking if the player wants to play again, add .lower() to the end of the input, and you can change the last lines as such:
if user_play_again != "y":
print("Have a great day! ")
break
You don't need to have a statement that evaluates if user_play_again == "y" just to have the else statement (unless you want there to be a separate action for it). You can evaluate the opposite (if user_play_again != "y") alone.
As I began to do earlier, you can put each ending variation into dictionaries and instead of having a different line for each end state check, you can evaluate the dictionary as a whole to streamline things a bit too.
These might not be the only things, and others might disagree with my changes, but it's a start of how I would rewrite the code.
The other answers have resolved the bugs in your code. This answer is meant to give you some ideas about how you might do things differently - specifically, a more object-oriented approach, and taking advantage of the standard library a bit more.
from enum import Enum
class Move(Enum):
ROCK = 0
PAPER = 1
SCISSOR = 2
def get_user_move():
moves = dict(zip("ABC", Move))
print("Options:")
for option, move in moves.items():
print(f"{option:>5}. {move.name.title()}")
prompt = "Enter your selection: "
while True:
user_input = input(prompt).upper()
if user_input in moves:
break
prompt = "Try again: "
return moves[user_input]
def main():
from random import choice
while True:
user_move = get_user_move()
computer_move = choice(tuple(Move))
print(f"\nYou picked {user_move.name.title()}")
print(f"The computer picked {computer_move.name.title()}")
if user_move is computer_move:
print("It's a tie!\n")
else:
winner = ("The computer", "You")[(computer_move.value + 1) % len(Move) is user_move.value]
print(f"The winner is: {winner}!\n")
return 0
if __name__ == "__main__":
import sys
sys.exit(main())

better write rock paper scissors (python)

Hey guys I'm new to python and I have made this simple rock paper scissors game but I wonder if there is a better way to program this without a super long if else statement.
import random
options = ["scissors", "paper", "rock"]
i = random.randint(0, (len(options) - 1))
playedHand = input("PLay rock, paper or scissors please: ")
computerPlayedHand = options[i]
if playedHand == "rock" and computerPlayedHand == "scissors":
print("the computer had scissors, you win")
elif playedHand == "rock" and computerPlayedHand == "paper":
print("the computer had paper, you lose")
elif playedHand == "rock" and computerPlayedHand == "rock":
print("the computer also had rock, its a tie")
elif playedHand == "paper" and computerPlayedHand == "rock":
print("the computer had rock, you win")
elif playedHand == "paper" and computerPlayedHand == "scissors":
print("the computer had scissors, you lose")
elif playedHand == "paper" and computerPlayedHand == "paper":
print("the computer also had paper, its a tie")
elif playedHand == "scissors" and computerPlayedHand == "paper":
print("the computer had paper, you win")
elif playedHand == "scissors" and computerPlayedHand == "scissors":
print("the computer also had scissors, its a tie")
elif playedHand == "scissors" and computerPlayedHand == "rock":
print("the computer had rock, you lose")
else:
print("please only state rock, paper or scissors")
Here is what I threw together trying to reuse your code where possible.
The key part is noticing that the options list can be treated as a cycle where an option always beats the next option. You can check this by finding the indices and then using modulo to make the indices cyclic.
import random
options = ["scissors", "paper", "rock"] # everything loses to the previous thing
comp_index = random.randint(0, (len(options) - 1))
playedHand = input("Play rock, paper or scissors please: ")
computerPlayedHand = options[comp_index]
try:
player_index = options.index(playedHand)
except ValueError:
print("please only state rock, paper or scissors")
else:
if player_index == comp_index:
res = "the computer also had {}, its a tie"
# the key part
elif (player_index - comp_index) % 3 == 1:
res = "the computer had {}, you lose"
else:
res = "the computer had {}, you win"
print(res.format(computerPlayedHand))
Using a dictionary to represent which hand beat which can significantly shorten your code. But since we are there, let's make this even neater with an object-oriented solution.
import random
class Hand:
_ordering = {
'rock': 'scissor',
'scissor': 'paper',
'paper': 'rock'
}
def __init__(self, kind):
if kind in self._ordering:
self.kind = kind
else:
raise ValueError(
"It's rock, paper, scissor... Not rock, {}, scissor.".format(kind)
)
#classmethod
def random_hand(cls):
return cls(random.choice(list(cls._ordering)))
def beats(self, other):
return self._ordering[self.kind] == other.kind
playedHand = Hand(input("Play rock, paper or scissors please: "))
computerPlayedHand = Hand.random_hand()
if playedHand.beats(computerPlayedHand):
print('You won! The computer had {}.'.format(computerPlayedHand.kind))
elif computerPlayedHand.beats(playedHand):
print('You lost... The computer had {}.'.format(computerPlayedHand.kind))
else:
print("It's a tie.")
You don't need to use any "if" statements other than typical error management. Look at the following example:
import random
def play():
table = [[2, 0, 1],
[1, 2, 0],
[0, 1, 2]]
options = ["Rock", "Paper", "Scissors"]
results = ["Defeat", "Win", "Tie"]
conv = {"R": 0 , "P": 1, "S": 2}
while True:
i = random.randint(0, (len(options) - 1))
p = input("Play rock, Paper or Scissors please (R, P, S): ")
if p not in conv.keys():
print("Unavailable option. Left the Game.")
return
print("Computer played %s. You have a %s"%(options[i], results[table[conv[p]][i]]))
play()
If you have a table like this:
# Rock Paper Scissor
# Rock 2 0 1
# Paper 1 2 0
# Scissor 0 1 2
...you can make the user play in rows, and the computer in columns. The result is being indexed directly by whatever is the number in the table. Thus playing the game in the example would look like this:
Here's another possible version:
import random
try:
options = [('rock', 'scissors'), ('paper', 'rock'), ('scissors', 'paper')]
human_choice = int(input("Play rock(0), paper(1) or scissors(2) please: "))
human_hand = options[human_choice]
computer_hand = options[random.randint(0, (len(options) - 1))]
text = "the computer {} {}, {}"
if human_hand[0] == computer_hand[0]:
print(text.format("also had", computer_hand[0], "it's a tie"))
elif human_hand[1] == computer_hand[0]:
print(text.format("had", computer_hand[0], "you win"))
else:
print(text.format("had", computer_hand[0], "you lose"))
except Exception as e:
print("please only state rock, paper or scissors")

Categories

Resources