[Tutor] While loop issue, variable not equal to var or var
steve at pearwood.info
Sat Jul 12 11:28:54 CEST 2014
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
py> "Hello World!".casefold()
but it can make a difference for non-English languages:
py> "Große".lower() # German for "great" or "large"
More information about the Tutor