Here is the list of the most common Python errors we have seen students experience in Mimir Classroom. The list of errors will continue to grow as we learn from students' work and as instructors like you send recommendations.

IndentationError

This error means that you have inconsistent indenting in your code. Check the line number reported by this error and double check that your indents around compound statements (conditionals and loops) and functions are consistent. If you have trouble solving this, ensure that all of your indents are the same. For example, mixing whitespace based indents and tabs based indents can cause this error.

SyntaxError: invalid syntax:

This is a very broad error most often caused by one of the following:

  1. Forgetting parentheses around function calls and nested function calls.

  2. Forgetting colons at the conditionals (if statements) and loops.

  3. Trying to use a python protected word as a variable name.

  4. You tried to create a variable that doesn’t start with a letter or underscore.

  5. You used = instead of == when comparing that two variables are equal.

NameError: global name

This error occurs when Python encounters a variable that it does not recognize. Make sure that you initialize your variables before you use them and check for typos in your variables names. Remember that Python is case sensitive.

IndexError: list index out of range

This error occurs when you try to access a spot in a list that does not exist. For example, if you have a list with 3 items called sampleList, then you can access the three items in the list :

sampleList[0] // First item

sampleList[1] // Second item

sampleList[2] // Third item

Indexes in python always start at 0 and end at n-1 where n is the size of the list.

TypeError: Can't convert 'int' object to str implicitly

This error happens when you try to concatenate an int into a string. Try surrounding your number variable with the str( ) function to convert it into a string.

SyntaxError: EOL while scanning string literal

This error usually occurs if you forget a quote at the beginning or end of a string.

EOFError: EOF when reading a line

This error usually occurs when one of your statements is inconclusive - typically due to syntax mistakes or malformed statements. For example:

user_Input == input("");

Did this answer your question?