Question: What is wrong with this code? This is for a simple rock paper scissors game in Python but I cannot get it right. import random

What is wrong with this code? This is for a simple rock paper scissors game in Python but I cannot get it right.

import random

def main(): print ("Welcome to rock, paper, scissors!") computer = 0 person = 0 choice(computer, person) winner(computer,person)

def choice(computer, person): print("What is your choice 1 = rock 2 = paper 3 = scissors?") person = int(input("Your choice: ")) def pc(computer, person): computer = random.randint(1,3) print("The computer chose", computer) def winner(computer,person): while computer == person: pc(computer,person) if (computer == person): print("It's a draw, try again") choice(computer, person) else: if(computer == 1 and person == 3): print("Computer wins") print("Rock beats scissors") elif(computer == 3 and person == 1): print ("You win!") print("Rock beats scissors") else: if(computer == 1 and person == 2): print("You win!") print("Paper beats rocks") elif(computer == 2 and person == 1): print("Computer wins") print("Paper beats rock") else: if(computer == 3 and person ==2): print("Computer wins") print("Scissors beat paper") elif(computer == 2 and person == 3): print("You win!") print("scissors beat paper") else: print("Your selection is not valid") main()

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!