Automatic text color choice inconsistent with example code

I don’t have a specific link to provide, but the colors of the parts of the line of code in the sample text are not accurately mimicked (at least on my Mac) in the code editor. This is true regardless of which class I’m working through.

As an example, when I put a field name in some of the SQL training in my code editor, it keeps the same light blue as the code before it. It does not turn white like the sample code until I add a second variable.

It’s a small thing, and does not affect me too badly because I have some experience with code and code syntax already. But, it might be confusing for true beginners.

We get people asking about this every now and again, but ultimately the IDE - whether that’s the code editor in Codecademy, or one running locally on your computer - is there to help the programmer out, not to guarantee that you’ll write 100% functional and absolutely correct code all the time.

Whenever someone pops up and says “my text for xyz is the wrong colour”, we generally set them right with “it probably doesn’t matter, if the code works!”. :slight_smile:

Agreed it works, I just mean if a complete beginner is using the color to learn the parts of code, it might get confusing to them.

But if it’s something that depends on the IDE, I take your point that there’s only so much you can do about it.

:slightly_smiling_face:

1 Like

I have a similar question. Do the text colors mean anything?? I can’t figure out a pattern.

Hi there.

Your code editor or IDE may show your code in one or more colours as you write it, to make it easier for you to distinguish between the different components of the program.

Take the following as an example:

def catchphrase(name, phrase):
    print(f"{name}'s catchphrase is '{phrase}'.")

people = [
    {"name" : "Brian", "phrase" : "People call me the Bry man..."},
    {"name" : "Chuck", phrase : "Whammmy!"},
    {"name" : "Ron", "phrase" : "Stay classy, San Diego."},
    {"name" : "Brick", "phrase" : "I love lamp!"}
    ]

for person in people:
    catchphrase(person["name"], person["phrase"])

As you can see, the linter is applying distinct formatting to various parts of the program such as keywords (like def and for), interpolated variables in my string like {name}, and string literals like the key-value pairs in my dictionary (similar to a JavaScript object, if you’re unfamiliar with Python).

The colours of the text make no difference to whether the program runs, it just makes it easier to quickly identify certain parts of it. This is the same program, just without the extra formatting:

def catchphrase(name, phrase):
    print(f"{name}'s catchphrase is '{phrase}'.")

people = [
    {"name" : "Brian", "phrase" : "People call me the Bry man..."},
    {"name" : "Chuck", phrase : "Whammmy!"},
    {"name" : "Ron", "phrase" : "Stay classy, San Diego."},
    {"name" : "Brick", "phrase" : "I love lamp!"}
    ]

for person in people:
    catchphrase(person["name"], person["phrase"])

You may have noticed that it’s much easier to spot the error I’ve left in the program in the top block of code, where the linter has styled the text. The same error exists in the bottom program, of course, but quickly spotting it is a bit trickier.

There should be some consistency to the styling that you see in your editor, but remember it’s only there to make your life easier as the programmer. :slight_smile:

1 Like