While Loop Fail - Caesar Cipher
I'm having a problem where when I ask my program to quit out it prints like I ask it to, however shows my menu of options as well continuously. So I'm getting this: >>> (
Solution 1:
x != 'q' or 'Q'
is being handled as (x != 'q') or 'Q'
, and 'Q' is always True.
It would better be:
x not in 'qQ'
or x.lower() != 'q'
Solution 2:
Your problem is this line:
while x != 'q' or 'Q' :
The problem is that Q
itself will always return True
, so the expression will always be true. Try changing the line with:
while x != 'q' and x != 'Q' :
Post a Comment for "While Loop Fail - Caesar Cipher"