4. Simple errors


Hi! I have a question regarding this exercise: https://www.codecademy.com/courses/python-beginner-en-cxMGf/0/4?curriculum_id=4f89dab3d788890003000096#

I was wondering the reason I should use "and" instead of "or" in the exercise. In my understanding, if I use "and", means this And that. But if I use "or", means either this or that. After trying a couple of times this exercise, I read the Hint and it said that I should use "and", which I did not expect. I mean, if I use "and" shouldn't the answer be y AND n instead of y OR n?

I attach here the instructions with my code. Thanks for any help :slight_smile:

Fill in the loop condition so the user will be prompted for a choice over and over while choice does not equal 'y' and choice does not equal 'n'.

choice = raw_input('Enjoying the course? (y/n)')

while choice != 'y' and choice != 'n':  # Fill in the condition (before the colon)
    choice = raw_input("Sorry, I didn't catch that. Enter again: ")


i know it is lazy, but i wrote this recently:

it should shed some light on the situation, let me know if you need more help

in short, using or won't work.


Oh thank you so much! Thanks to your explanation now I understand why my code didn't work.


True or False # true
True and False # false

Good you understand now :slight_smile:


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.