Question: I am having a hard time getting my code to work to match the outputs in the image. Below is my current code. Please rewrite

I am having a hard time getting my code to work to match the outputs in the image. Below is my current code. Please rewrite the code to work correctly. Thanks
import random
ROCK =1
PAPER =2
SCISSORS =0
# Read random seed to support testing (do not alter) and starting credits
seed = int(input())
# Set the seed for random
random.seed(int(seed))
# Read player names and number of rounds
player1_name = input()
player2_name = input()
rounds = int(input())
# Ensure rounds is positive
while rounds =0:
print("Rounds must be >0")
rounds = int(input())
print(f"{player1_name} vs {player2_name} for {rounds} rounds")
# Play rounds
player1_wins =0
player2_wins =0
ties =0
for _ in range(rounds):
# Generate random hand signals for both players
p1_signal = random.randint(0,2)
p2_signal = random.randint(0,2)
# Convert hand signals to string
hand_map ={
ROCK: "rock",
PAPER: "paper",
SCISSORS: "scissors"
}
# Convert hand signals to string
p1_hand = hand_map[p1_signal]
p2_hand = hand_map[p2_signal]
if p1_signal == ROCK:
if p2_signal == SCISSORS:
print(f"{player1_name} wins with rock")
else:
print(f"{player2_name} wins with paper")
elif p1_signal == PAPER:
if p2_signal == ROCK:
print(f"{player1_name} wins with paper")
else:
print(f"{player2_name} wins with scissors")
else: # p1_signal == SCISSORS
if p2_signal == PAPER:
print(f"{player1_name} wins with scissors")
else:
print(f"{player2_name} wins with rock")
 I am having a hard time getting my code to work

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!