29 Common Beginner Python Errors PDF
29 Common Beginner Python Errors PDF
Attribute Error
SyntaxError
You've forgotten the quotes around a string You have forgotten to put a colon at the end of a def/if/for line You have different number of open and close brackets in a statement
NameError
You've misspelt a variable, function or method name You've forgotten to import a module You've forgotten to dene a variable Your code uses a variable outside the scope where it's dened Your code calls a function before it's dened You're trying to print a single word and have forgotten the quotes
TypeError
You're trying to use an operator on the wrong type of objects An object which you expect to have a value is actually None You've used non-integer numbers in a list slice You've called a method/ function with the wrong number or type of arguments
I am reading a le but getting no input You have already read the contents of the le earlier in the code, so the cursor is at the end.
neither loops
A list which should have a value for every iteration only has a single value You have dened the list inside the loop: move it outside A loop which uses the range function misses out the last value The range function is exclusive at the nish: increase it by one. I am trying to loop over a collection of strings, but am getting individual characters You are iterating over a string by mistake I am trying to write multiple lines to a le but only getting a single one You have opened the le inside the loop: move it outside
Indentation Error
You've used a mixture of tabs and spaces You haven't indented all lines in a block equally
IOError
KeyError
http://pythonforbiologists.com
also check...