Quite new to coding and I'm trying to make a rock paper scissors game. I'm trying to get it to loop back around to the start when it is done, and print the amount of wins and losses the player has. Keep getting errors that I have no clue how to fix and it's getting slightly frustrating.
Any help would be great!
The Errors
The Code
Код: Выделить всё
import random
loss = 0
wins = 0
rps = ["Rock", "Paper", "Scissors"]
op = random.choice(rps)
print(op)
while True:
pl = str(input("Choose your weapon! Rock, Paper or Scissors: ")).upper()
print(f"Wins: {wins}")
print(f"Losses: {loss}\n")
if pl in ["PAPER", "P"] and op in ["Paper"]:
print(f"Opponent has chosen {op}!\nIt's a draw!")
elif pl in ["PAPER", "P"] and op in ["Rock"]:
print(f"Opponent has chosen {op}!\nYou Win!")
wins += 1
elif pl in ["PAPER", "P"] and op in ["Scissors"]:
print(f"Opponent has chosen {op}!\nYou Lose!")
loss += 1
elif pl in ["ROCK", "R"] and op in ["Rock"]:
print(f"Opponent has chosen {op}!\nIt's a draw!")
elif pl in ["ROCK", "R"] and op in ["Scissors"]:
print(f"Opponent has chosen {op}!\nYou Win!")
wins += 1
elif pl in ["ROCK", "R"] and op in ["Paper"]:
print(f"Opponent has chosen {op}!\nYou Lose!")
loss += 1
elif pl in ["SCISSORS", "S"] and op in ["Scissors"]:
print(f"Opponent has chosen {op}!\nIt's a draw!")
elif pl in ["SCISSORS", "S"] and op in ["Rock"]:
print(f"Opponent has chosen {op}!\nYou Lose!")
loss += 1
elif pl in ["SCISSORS", "S"] and op in ["Paper"]:
print(f"Opponent has chosen {op}!\nYou Win!")
wins += 1
Источник: https://stackoverflow.com/questions/664 ... if-keyword