Problem I have with a while loop/boolean/or

Paul Rubin http
Tue Mar 13 18:43:02 EDT 2007


"israphelr at googlemail.com" <israphelr at googlemail.com> writes:
> while (hint != 'n') or (hint != 'y'):
>     hint = raw_input("Please specify a valid choice: ")
> 
> ---------------------------------------------
> 
> so everytime I run the program, and enter my choice as y or n, I'm
> told to 'Please Specify a valid Choice Again' and can't get out of the
> loop.

Suppose your hint is 'y'.  Ask yourself these two questions:

  1. Is (hint != 'n') true?
  2. Is (hint != 'y') true?

Now ask yourself what the condition in your while loop says.



More information about the Python-list mailing list