Python Forum
Ending loop with string (capital & lowercase) - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Ending loop with string (capital & lowercase) (/thread-5800.html)



Ending loop with string (capital & lowercase) - MattWilk97 - Oct-22-2017

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!


RE: Ending loop with string (capital & lowercase) - buran - Oct-22-2017

you are right to use lower(), however, why you want it to be different from ALL CAPS QUIT
 :-)


RE: Ending loop with string (capital & lowercase) - MattWilk97 - Oct-22-2017

Thanks! I was asked to include these variations in order to make the script easier to use for end-users...


RE: Ending loop with string (capital & lowercase) - sparkz_alot - Oct-22-2017

Perhaps:
quit = ['q', 'Q', 'quit', 'Quit', 'QUIT']
then test if 'custname' is in 'quit'