0

This is my first little program I have created. Can anyone help me with making it so it works with the first letter being capitalized?

# Rock Paper Scissors

import time
import random

user_wins = 0
computer_wins = 0

def RockPaperScissors():
    user_choice = input("Enter your choice in a game of Rock, Paper, Scissors: ")

    if user_choice == "rock" or user_choice == "paper" or user_choice == "scissors":
        print("Good choice, lets see who wins.")
        time.sleep(1.5)
    else:
        print('Please enter either "rock", "paper", or "scissors"')

    computer_choice = ["rock", "paper", "scissors"]
    rand_choice = random.choice(computer_choice)

    print("The computer chose", rand_choice)

    if user_choice == "rock" and rand_choice == "scissors":
        print("You won!")
    elif user_choice == "scissors" and rand_choice == "rock":
        print("The computer won, try again.")
    elif user_choice == "paper" and rand_choice == "rock":
        print("You won!")
    elif user_choice == "rock" and rand_choice == "paper":
        print("The computer won, try again")
    elif user_choice == "scissors" and rand_choice == "paper":
        print("You won!")
    elif user_choice == "paper" and rand_choice == "scissors":
        print("The computer won, try again")
        

RockPaperScissors()

I also have a slight issue with if you capitalize the first letter, the program does not run as intended. Appreciate the help!

  • Better to ask this over at https://codereview.stackexchange.com/ instead since your program is working fine, but you are seeking opinions on improving it. Also, great job on getting through your first program :) That's no small feat. Lastly, regarding capitalization/comparison, consider converting your user input to lowercase: https://stackoverflow.com/questions/6797984/how-do-i-lowercase-a-string-in-python – JNevill Jan 09 '23 at 15:57
  • 2
    @JNevill If this was asked on Code Review without some editing it would be closed as `Code not working as intended` because of the problem with capitalizing the first character. When you redirect people to code review please send them to the help page https://codereview.stackexchange.com/help/how-to-ask. – pacmaninbw Jan 09 '23 at 16:23
  • `user_choice = user_choice.lower()` – JonSG Jan 09 '23 at 16:37
  • @pacmaninbw I intrepreted this as two questions. One was appropriate for stackoverflow "I would like this to work with capitalized letters and I can't crack the code", and completely separately "Any suggestions for code improvement". Reference to how-to-ask is a good call :) – JNevill Jan 09 '23 at 16:51

0 Answers0