That's nice. Thanks!<br>V<br><br><div class="gmail_quote">On Sun, Aug 23, 2009 at 5:02 PM, Dennis Lee Bieber <span dir="ltr"><<a href="mailto:wlfraed@ix.netcom.com">wlfraed@ix.netcom.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
On Sun, 23 Aug 2009 10:04:57 -0500, Victor Subervi<br>
<<a href="mailto:victorsubervi@gmail.com">victorsubervi@gmail.com</a>> declaimed the following in<br>
gmane.comp.python.general:<br>
<div class="im"><br>
> Hi;<br>
> I have the following:<br>
><br>
> style = raw_input('What style is this? (1 = short, 2 = long): ')<br>
> flag = 0<br>
> while flag == 0:<br>
>   if (style != 1) or (style != 2):<br>
>     style = raw_input('There was a mistake. What style is this? (1 = short,<br>
> 2 = long): ')<br>
>   else:<br>
>     flag = 1<br>
><br>
</div>        Ugh... Unless you are using an archaic version of Python, the<br>
language has support for booleans...<br>
<br>
done = False<br>
while not done:<br>
        ...<br>
        done = True<br>
<br>
<br>
        You fail to convert the character input from raw_input into an<br>
integer for comparison... Oh, and you say the input is wrong if it is<br>
NOT 1 OR NOT 2... 1 is not 2, and 2 is not 1, so... even if you did<br>
convert to an integer, it would be rejected.<br>
<br>
        Consider:<br>
<br>
-=-=-=-=-=-=-=-<br>
while True:<br>
    charin = raw_input("What style is this? (1: short, 2: long): ")<br>
    try:<br>
        style = int(charin)<br>
    except:             #I know, should not use naked except clause<br>
        print ("The input '%s' is not a valid integer value; try again"<br>
                % charin)<br>
    else:<br>
        if style in (1, 2): break<br>
        print ("The input value '%s' is not in the valid range; try<br>
again"<br>
               % style)<br>
-=-=-=-=-=-=-=-<br>
{Watch out for line wraps}<br>
Works in Python 2.5<br>
<br>
E:\UserData\Dennis Lee Bieber\My Documents>python Script1.py<br>
What style is this? (1: short, 2: long): ab1<br>
The input 'ab1' is not a valid integer value; try again<br>
What style is this? (1: short, 2: long): 1a<br>
The input '1a' is not a valid integer value; try again<br>
What style is this? (1: short, 2: long): 12<br>
The input value '12' is not in the valid range; try again<br>
What style is this? (1: short, 2: long): 2<br>
<br>
E:\UserData\Dennis Lee Bieber\My Documents><br>
<br>
--<br>
        Wulfraed         Dennis Lee Bieber               KD6MOG<br>
        <a href="mailto:wlfraed@ix.netcom.com">wlfraed@ix.netcom.com</a>   <a href="HTTP://wlfraed.home.netcom.com/" target="_blank">HTTP://wlfraed.home.netcom.com/</a><br>
<font color="#888888"><br>
--<br>
</font><div><div></div><div class="h5"><a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
</div></div></blockquote></div><br>