On Mar 13, 5:34 pm, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
> Hi all.
>
> I have a problem with some code :(
>
> -----------
>
> hint = raw_input("\nAre you stuck? y/n: ")
> hint = hint.lower()
>
> while (hint != 'n') or (hint != 'y'):
>     hint = raw_input("Please specify a valid choice: ")
>

I'd even make it a little more bullet-proof by using lower()

while hint.lower() not in ('y','n'):
  stuff

That way if the user types in 'Y' on 'N' it will still work.  I've
even gone further on occasion

while hint.lower()[0] not in ('y','n'):
  stuff

so if they type 'Yes' or 'No' you're still good.

--greg

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to