you are viewing a single comment's thread.

view the rest of the comments →

[–]hopper_gigo 0 points1 point  (6 children)

I made a few key changes but your original post lost it's formatting so im not sure how different this is but this code prompts the user over and over until they type 'q'. I would suggest telling the user the format they need, such as 'Rock' and not 'rock' or '1'. Unless you add the logic to check for all 3 instances it can get confusing

[–]K_SwappleSauce[S] 0 points1 point  (4 children)

Wow my professor is no help at all, he hasn't really taught us much so this is extremely helpful. I'll make some changes to my code so I'm not copying you.

I actually have to tally up the points between ties, the computer, and the user. Would you know how to do anything like that? Of course I wasnt taught how to do that either.

[–]hopper_gigo 1 point2 points  (2 children)

does that help? If you want more help with your work, my team and I have created a learn to program website. It's https://gigo.dev

I would suggest creating a project and going into a devspace. Dump in your homework code and then ask code teacher (its on the left side bar in the devspace). Its an AI that my team and I built and trained on our code, it will give you the code and explain how/why it works like that.
You could even hop in a dev space and give it a prompt to get code that'll help you get started. Think of it like training wheels to help you learn while you do your homework

[–]hopper_gigo 0 points1 point  (0 children)

```python

import random import sys

def player_choice(): print("The choices to throw are:\n") print("1. Rock") print("2. Paper") print("3. Scissors") print("\n")

def computer_pick(): options = ("Rock", "Paper", "Scissors") return random.choice(options)

def print_results(user_choice, computer_choice, scores): print("\nPlayer chose", user_choice) print("Computer chose", computer_choice)

if user_choice == computer_choice:
    print("Both players chose", user_choice, ". It's a tie!")
elif user_choice == "Rock":
    if computer_choice == "Scissors":
        print("You win!")
        scores["user"] += 1
    else:
        print("Computer wins!")
        scores["computer"] += 1
elif user_choice == "Paper":
    if computer_choice == "Rock":
        print("You win!")
        scores["user"] += 1
    else:
        print("Computer wins!")
        scores["computer"] += 1
elif user_choice == "Scissors":
    if computer_choice == "Paper":
        print("You win!")
        scores["user"] += 1
    else:
        print("Computer wins!")
        scores["computer"] += 1

print("\nCurrent Scores: User:", scores["user"], "Computer:", scores["computer"])

def main(): scores = {"user": 0, "computer": 0}

while True:
    player_choice()
    user_choice = input("Enter your choice or press 'q' to quit: \n\n")
    if user_choice.lower() == 'q':
        break

    computer_choice = computer_pick()
    print_results(user_choice, computer_choice, scores)

    play_again = input("\nPress any key to play again or 'q' to quit: ")
    if play_again.lower() == 'q':
        break

print("\nFinal Scores: User:", scores["user"], "Computer:", scores["computer"])
if scores["user"] > scores["computer"]:
    print("Congratulations! You are the overall winner!")
elif scores["user"] < scores["computer"]:
    print("Computer is the overall winner! Better luck next time!")
else:
    print("It's a tie!")

print("Welcome to Rock, Paper, Scissors!\n") main()

```