Game Development Reference
In-Depth Information
In the above case, the programmer used = (the assignment operator) instead of == (the
equals comparator operator). Python never expects assignment statements where there
should be a condition.
def foo(:
In the above case, the programmer forgot to match the ending ) closing parenthesis.
def foo()
In the above case, the programmer forgot to put the colon at the end of the def
statement. This can also happen with for , while , if , elif , and else statements.
ImportError: No module named raandom
This error shows up when you try to import a module that does not exist. Most likely,
you have a typo in the module name. For example, you may have typed raandom instead
of random .
SyntaxError: EOL while scanning string literal
print('Hello world!)
print("Hello world!')
This error happens when you do not have two quote marks for a string, or you use
different quote marks for the same string. Look at these two examples:
AttributeError: 'str' object has no attribute 'lowerr'
'Hello'.lowerr()
'Hello'.append('x')
This error appears when you call a method or access an attribute that does not exist. This
is most likely because 1) you have a typo in the method or attribute name, or 2) you are
calling the method or attribute on a value that is the wrong data type. For example, strings
have a method named lower() , but not lowerr() (that is a typo). And the append()
method is a list method, so calling it on a string value will cause this error.
Search WWH ::




Custom Search