On 11/07/14 22:16, Steve Rodriguez wrote:
Hey guys n gals,
New to python, having some problems with while loops, I would like to
make a program quick once q or Q is typed, but thus far I can only get
the first variable to be recognized.
> My code looks like:
>
> message = raw_input("-> ")
> while message != 'q':
Peter has given a comprehensive reply.
There are two other options he didn't mention.
1) Use 'and' instead of 'or':
while message != 'q' and message != 'Q':
2) Better (IMHO) is to convert message to lower case (or upper if
you prefer) and only do one comparison:
while message.lower() != 'q':
HTH,
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.flickr.com/photos/alangauldphotos
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor