I tried going through the first Beau Canes course for Python beginners on Youtube. I entered the code in the Replit browser for the “rock paper scissors” game and the program isn’t running. No error message. Is there any way to get support for this course. Right out of the gate, I’m dead in the water. Thanks folks.
Can you post the code you have written (the replit link would be best) and explain what you expect to happen that is not happening when you run the code?
Thanks for the reply Randell. At this point in the exercise, when I run the code, the console should be asking for input like this- input("Enter a choice (rock, paper, scissors: "). Instead, all I get is a cursor. That’s it. No error, nothing. I’ve checked for typos multiple times. Here’s the Replit link:
https://replit.com/@jcamp2875/JimsReplit#main.py
Here’s the code so far:
import random
def get_choices():
player_choice = input("Enter a choice (rock, paper, scissors: ")
options = ["rock", "paper", "scissors"]
computer_choice = random.choice(options)
choices = {"player": player_choice, "computer": computer_choice}
return choices
def check_win(player, computer):
print(f"You chose {player}, computer chose {computer}")
if player == computer:
return "It's a tie!"
So line #4- player_choice = input("Enter a choice (rock, paper, scissors: ") calls the function “input” which passes the text string argument (“Enter a choice (rock,paper,scissors.”) and assigns the response to the variable “player_choice,” no? Didn’t I call the function “input?” Thanks for your help.
The input function that assigns a value to player_choice will never be called unless you call the function get_choices. The function check_win is also not going to execute unless you call it.
Got it. Thanks. Program is now generating an error for the check_win function- “TypeError: ‘function’ object is not subscriptable” Is that a typo or something else?
Thanks again for your help…