Steven D'Aprano <st...@pearwood.info> Wrote in message: > On Sat, Jul 12, 2014 at 09:33:20AM +0100, Alan Gauld wrote: > >> 2) Better (IMHO) is to convert message to lower case (or upper if >> you prefer) and only do one comparison: >> >> while message.lower() != 'q': > > I second this advice, but with a slight modification. > > If you're using Python 3.3 or higher, it is better to use > message.casefold rather than lower. For English, there's no real > difference: > > py> "Hello World!".casefold() > 'hello world!' > > > but it can make a difference for non-English languages: > > py> "Große".lower() # German for "great" or "large" > 'große' > py> "Große".casefold() > 'grosse' >
I don't remember my high school German enough to remember if the ß character is an example, but in various languages there are characters that exist only in uppercase, and whose lowercase equivalent is multiple letters. Or vice versa. And characters that have multiple valid spellings in uppercase, but only one in lowercase. If the latter is true for German, perhaps GROSSE and GROßE are valid uppercase, but only grosse for lowercase. -- DaveA _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor