Python Forum

Full Version: Ending loop with string (capital & lowercase)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
custname = input("Enter customer's name: ")
while custname.lower () != "QUIT":

I am needing to end the loop when customer's name is "Quit", "quit", and "QUIT". Currently, I have yet to even come close to the desired end of the loop using these names. Any help/guidance would be greatly appreciated!
you are right to use lower(), however, why you want it to be different from ALL CAPS QUIT
 :-)
Thanks! I was asked to include these variations in order to make the script easier to use for end-users...
Perhaps:
quit = ['q', 'Q', 'quit', 'Quit', 'QUIT']
then test if 'custname' is in 'quit'