On 12/18/2025 1:34 PM, Gregg Drennan wrote:
No chatbot involved.  I was typing this on my phone in bed last night and didn't have a Python interpreter handy that I could verify this with.  I will certainly check this.

I apologise. I thought your post sounded chatbotty, especially at the end. I have to admit I only tested with punctuation, not a wide range of unicode characters, but heck that's what your post mentioned.

Apparently if you want to use casefold() to compare characters, you should call it on both, and not assume it will just give you lowercase. There are only a few, very few, characters where casefold() and lower() give different results. Rare, but the German ß is one of them. If you program using a German keyboard you probably know this (I don't and didn't).

In any case, since verifying that a valid choice was made was made is done in the same IF statement as the check for None, it seems to be a moot point.

Calling lower() on None will cause an Exception so I would always recommend making that check on any user input.

Yes, using casefold to deal with non-ascii characters is a good point. In this case, we don't care what the input was if it's not one of the four valid choices...we just treat it as invalid and prompt the player to enter a valid choice.


On Thu, Dec 18, 2025, 8:21 AM Thomas Passin <[email protected] <mailto:[email protected]>> wrote:

    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] <mailto:[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
    <https://mail.python.org/mailman3//lists/python-list.python.org>
     >>

-- https://mail.python.org/mailman3//lists/python-list.python.org
    <https://mail.python.org/mailman3//lists/python-list.python.org>


--
https://mail.python.org/mailman3//lists/python-list.python.org

Reply via email to