Reputation: 13
Ok so in this I have an issue where if the answer is "N"
then it will still continue to the else
statement. How do I fix this? (this is all in a function, edit: with other if statements that work fine)
if command == "Exit":
exit = 1
while exit == 1:
print("Quit? Y/N:", end="")
ex = input()
if ex == "Y":
quit()
elif ex == "N":
break
else:
print("Err")
Upvotes: 0
Views: 80
Reputation: 547
The Code Seems To work Fine.
I assumed what you Want to do is : on Entering Exit ask user Y or N if user enters Y you quit the program if user enters N you want to break out of while loop. It works fine for both the cases can you add something else to the question to illustrate the problem.
I would also recommend you to try using return statnment while trying to break from multiple loop or if you are creating function for this purpose.
Make sure You are not entering small alphabets . You can use .upper() function to make sure you always use uppercase.
Upvotes: 1