Jul-05-2023, 03:24 PM
(This post was last modified: Jul-05-2023, 03:28 PM by deanhystad.)
Full program:
import random moves = ["rock", "paper", "scissors"] def get_choices(): player_choice = input("Enter a choice of rock, paper, or scissors: ") computer_choice = random.choice(moves) choices = {"player": player_choice, "computer": computer_choice} return choices def check_win(player, computer): print("You chose " + player + " and the computer chose " + computer) if player == computer: return "It's a tie" elif player == "rock": if computer == "scissors": return "Rock beats scissors" else: return "Paper beats rock" elif player == "paper": if computer == "rock": return "Paper beasts rock" else: return "Scissors beats paper" elif player == "scissors": if computer == "paper": return "Scissors beats paper" else: return "Rocks beats scissors" choices = get_choices() results = check_win(choices["player"],choices["computer"]) print(results)
deanhystad write Jul-05-2023, 03:28 PM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.