Simple Errors


#1



https://www.codecademy.com/courses/python-beginner-en-cxMGf/0/4?curriculum_id=4f89dab3d788890003000096


My code is working exactly as I want it to and how I think the instructions require me to. What is wrong?
The instructions list:

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'.


I expected my code to be accepted as it generates no Python errors and it works as designed :slight_smile:


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

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


#2

in the loop condition, why do you use <>?


#3

I use <> because it's a valid alternative to != is it not?


#4

valid? Yes. Common? Not that i know. Does the exercise like it? Certainly not, as you can tell by the error message thrown by the exercise. Just use !=


#5

The emulator accepts it just fine, it works as intended and generates no errors. If I recall correctly, earlier exercises have accepted the use of it (or maybe just look at the result).

Because of this I did some research and see that <> is apparently obsolescent from Python 3 on, so using != is the way to go, obviously. Maybe the feedback should be to recommend using != instead of <>
There is nothing wrong with my code for the version of python it apparently uses, so I think it's wrong to deny the validity of my code because of that.

Thank you for your quick answer!


#6

well, working in codecademy besides the errors generated by the python interpreter ou also have to deal with the lesson validation (SCT) , which doesn't always give you all the freedom (this would make exercise validation very difficult sometimes)

well, there is probably a good reason <> is obsolescent, so i would recommend the use of !=


#7

Understood, I'll do that from now on.


#8