in reply to Basic 'while' loop problem
Others have mentioned chomp which is good advice - but I also wonder if you have a logic problem.
Your loop condition basically says "try again if input is not g, or not l". So if the user types g, "not g" is false, but "not l" is true, so it complains.
If the condition for valid input is (l or g) then the logical negation of that is (not (l or g)) which can be written as (not l and not g).
So - you need an and instead of an or.
I hope that makes sense, apologies if I've misunderstood.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Basic 'while' loop problem
by BioBoy (Novice) on Oct 04, 2005 at 15:58 UTC |