Respuesta :
import random
name = input("Welcome! What's your name? ")
computer_choices = (["rock", "paper", "scissors"])
rounds = int(input("How many points do you want to play to, {}? ".format(name)))
user_total = 0
comp_total = 0
while user_total < rounds and comp_total < rounds:
user_choice = input("rock, paper, or scissors? ")
computer = random.choice(computer_choices)
if user_choice == computer:
print("It's a draw! You both threw {}".format(user_choice))
elif user_choice == "rock" and computer == "scissors":
user_total += 1
print("You threw rock and the computer threw scissors! You won!")
print("{}: {} point(s) out of {} point(s)".format(name, user_total, rounds))
print("Computer: {} point(s) out of {} point(s)".format(comp_total, rounds))
elif user_choice == "paper" and computer == "rock":
user_total += 1
print("You threw paper and the computer threw rock! You won!")
print("{}: {} point(s) out of {} point(s)".format(name, user_total, rounds))
print("Computer: {} point(s) out of {} point(s)".format(comp_total, rounds))
elif user_choice == "scissors" and computer == "paper":
user_total += 1
print("You threw scissors and the computer threw paper! You won!")
print("{}: {} point(s) out of {}".format(name, user_total, rounds))
print("Computer: {} point(s) out of {} point(s)".format(comp_total, rounds))
else:
comp_total += 1
print("You threw {} and the computer threw {}! You lost!".format(user_choice, computer))
print("{}: {} point(s) out of {}".format(name, user_total, rounds))
print("Computer: {} point(s) out of {} point(s)".format(comp_total, rounds))
print("The final scores are:")
print("{}: {} points".format(name, user_total))
print("Computer: {} points".format(comp_total))
if user_total > comp_total:
print("You won! Thanks for playing!")
else:
print("The Computer won! Thanks for playing")
I've tried to come up with something similar to what you wanted. If you have anymore question, I'll do my best to answer them.
Otras preguntas
