Write a program in which the player chooses rock, paper or scissors, and the computer randomly
chooses one of the three possibilities. If the player and computer choose the same item, it is a tie and
they should be asked to choose again. Continue as needed until someone wins. At the end, state the
winner and the choices made by the computer and player.
Rules: Rock beats scissors, scissors beats paper, and paper beats rock.
(In Python Please, I really need help!)

Write a program in which the player chooses rock paper or scissors and the computer randomly chooses one of the three possibilities If the player and computer c class=

Respuesta :

import random

import getpass

p1score = 0

p2score = 0

for i in range(3):

 player1 = getpass.getpass("Player 1, make your move: ").lower()

 player2 = "computer"

 if player2 == "computer":

   movenum = random.randint(1,3)

   if movenum == 1:

     player2 = "rock"

   if movenum == 2:

     player2 = "paper"

   if movenum == 3:

     player2 = "scissors"

 if player1 == player2:

   print("tie, try again")

 elif player1 == "rock" and player2 == "paper":

   p2score += 1

   print("Paper covers Rock, Player2 wins")

 elif player2 == "rock" and player1 == "paper":

   p1score += 1

   print("Paper covers Rock, Player1 wins")

 elif player1 == "scissors" and player2 == "paper":

   p1score += 1

   print("Scissors cut Paper, Player1 wins")

 elif player1 == "paper" and player2 == "scissors":

   p2score += 1

   print("Scissors cut Paper, Player2 wins")

 elif player1 == "rock" and player2 == "scissors":

   p1score += 1

   print("Rock breaks Scissors, Player1 wins")

 elif player1 == "scissors" and player2 == "rock":

   p2score += 1

   print("Rock breaks Scissors, Player2 wins")

print(f"**********\n"

     "**********\n"

     "**********\n"

     "FINAL SCORES: \n"

     f"Player 1 Score is {p1score} \n"

     f"Player 2 Score is {p2score}")

ACCESS MORE