Home > Blockchain >  Visual Studio Code Red Unerlines
Visual Studio Code Red Unerlines

Time:11-30

I started programming python in vsc. My problem is, that everything is underlined red but if I compile the code he is working. So the code doesn't seems to be wrong. enter image description here

Has anybody an idea what could cause this problem and how I can solve it?

CodePudding user response:

As mentioned in the comments, these are not syntax errors, but style errors. Python code usually follows the PEP8 standard found at https://www.python.org/dev/peps/pep-0008/

Your VSCode is likely using a python linter (style checker) that is trying to get you to follow this style. While it would be possibly to unconfigure this linter, it would be more preferable to adapt to following this style guide as it will make your code more consistent and more readable, especially if you begin to share this code with other python developers.

Another benefit of learning to follow this style for yourself is that it will help you to be better at reading python code written by others.

Following this style guide, your code may look something like this:

old_friends = {}

def older_friend(friends, age):
    for key, value in friends items():
        if value > age:
            old_friends[key] = value
    print(old_friends)
  • Related