Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Syntax Error: invalid syntax in an unexpected spot

Sometimes you run into a Syntax Error: invalid syntax and the error message indicates there is a problem with a line that looks totally fine. This usually happens when you have syntax errors right above the line indicated. Some common causes include missing colons and incorrectly paired parentheses/quotation marks.

Errors in your testing code

For most assignments, you will be asked to write your own set of tests for the assignment you are writing (see assignment spec for details).

Common error messages

(Where X is the name of one of the methods you wrote for this assignment.)

False is not true : Did not call X
False is not true : Note: This can sometimes happen if your tests don't run.
Try running them yourself. Did not call X: encountered error [Errno 2]
No such file or directory: 'file.txt'

Usual cause for error

Our tests are making sure your test cases actually test all of your code. If your test cases don’t actually call some of your methods, or your tests encounter some error that prevents them from calling all of your methods, it will end up failing our test.

Common things to check for

Code Quality tests

We use flake8 to automatically assess some aspects of code quality. flake8 messages have the following format:

<file name>:<row num>:<col num>: <error code> <error description>

For example, you might see

my_file.py:8:14: E703 statement ends with a semicolon

This means that in the file named my_file.py, on line 8 of the file there was a problem in the 14th character on that line. The error description says it says something about a semicolon.

You can always look up the flake8 error code (in this example E703) in our [flake8 reference]({{ vars.flake8_reference }}) to see a more detailed explanation of the error (with examples!).

[Quality] Contains all comments

This test is checking of all of the functions you wrote are documented as well as all of the modules (i.e., Python files) you submitted. Your doc-string comments should be under the function header and properly indented like the example below:

def add_two_numbers(a, b, return_zero=False):
    """
    This function returns the sum of the two given numbers a, b
    if return_zero is False. Otherwise returns 0.
    return_zero has False as its default value.
    """
    if return_zero:
        return 0
    else:
        return a + b

Your module comments should be a the top of each module.

Common things to look for

Program ran for too long

If you get an error message saying that your program ran for too long, it means our tests have timed out while executing your code.

Common things to check for