mardi 29 décembre 2020

How do I add a 'play again' option for the following game

I have tried to add a 'while True' loop but it shows the error 'str object is not callable'. Please help me on this one. I need an extension of this already written code game.

import random
user_score = 0
computer_score = 0
user_score = 0
computer_score = 0
input = input("Choose your move, Rock, Paper or Scissors: ").upper()
comp = ["ROCK", "PAPER", "SCISSORS"]
computer_move = random.choice(comp)

if input == "ROCK":
    if computer_move == "PAPER":
        print("You lost. Better luck next time!")
        computer_score += 1
    elif computer_move == "SCISSORS":
        print("You won! Well done.")
        user_score += 1
elif input == "PAPER":
    if computer_move == "ROCK":
        print("You won! Well done.")
        user_score += 1
    elif computer_move == "SCISSORS":
        print("You lost. Better luck next time!")
        computer_score += 1
elif input == "SCISSORS":
    if computer_move == "ROCK":
        print("You lost. Better luck next time!")
        computer_score += 1
    elif computer_move == "PAPER":
        print("You won! Well done.")
        user_score += 1
elif input == computer_move:
    print("It's a tie!")
print(f"Your Score: {user_score} ; Computer Score: {computer_score} ")



Aucun commentaire:

Enregistrer un commentaire