Re: Rock Paper Scissors Code Bug?
Thomas Passin <[email protected]> Thu, 18 Dec 2025 08:13:16 -0500
| Newsgroups | gmane.comp.python.general |
|---|---|
| Message-ID | <[email protected]> |
On 12/17/2025 10:43 PM, Gregg Drennan via Python-list wrote:
> The other recommendation i would make is to shorten the response the player
> needs to give when choosing their option. "R", "P", "S" is sufficient to
> determine the player's choice. Making the player enter the whole word
> introduces opportunity for misspellings. I would also allow the player to
> enter "Q" in case they decide to stop playing. And always check to make
> sure the player entered something and didn't just hit enter. Also don't
> use .lower() until you check to make sure you have a valid entry, the
> player might enter a character that can't be converted to lower case, like
> a number or punctuation.
See, here's the problem with relying on a chatbot. Calling lower() works
fine for a character that doesn't have a lowerclass version. It just
returns the original.
> while True:
> player_choice = input("Please enter your choice (Rock, Paper, Scissors,
> or Quit): "
> If not player_choice or player_choice[0] not in "RPSQrpsq": # check
> if None or invalid choice
> print("Invalid choice...")
> else:
> If player_choice[0].lower() == "q":
> print("Thanks for playing. Good-bye.")
> break
> # code to score the choices, blah, blah, blah
>
> Good luck with your new version!
>
> On Mon, Dec 8, 2025, 5:37 PM John Smith via Python-list <
> [email protected]> wrote:
>
>> Thanks for the recommendations. I'm building a whole new version based on
>> the old one, with simpler code and functions to find win stats.
>> --
>> https://mail.python.org/mailman3//lists/python-list.python.org
>>