3. Newbie + Copy-
Paste
Space
Tab
This error primarily occurs because there are space or
tab errors in your code.
Some of the causes of the error are:
• You are using both spaces and tabs in your code.
• You have placed some indent wrong..
• You forgot to indent the compound statements such
as ‘if’, ‘for’, ‘while’ etc.
• You forgot to indent user-defined functions or
classes.
INDENTATION ERROR
4. TYPE ERROR
TypeError is thrown when an operation or function is applied
to an object of an inappropriate type.
Because the plus operator (+) expected two numeric
parameters, Python throws a TypeError, telling us that one of
our parameters was of the incorrect type.
5. VALUE ERROR
To encounter a ValueError in Python means that is a problem with the content
of the object you tried to assign the value to.
Imagine you have a dog and you try to put it in a fish tank. This would be an
example of a type error, because animals of type ‘dog’ certainly are not the
same as animals of type ‘fish’.
On the other hand, imagine we tried to put a Great Dane into a Chihuahua’s
kennel. This would be a problem with the value of the dog, because although
they are both of type ‘dog’, a Chihuahua’s kennel would not be able to accept
a dog the size of a Great Dane.
6. SYNTAX ERROR
• Basic type of error in Python
• Syntax Error arise when the Python
parser is unable to understand the
code
• Most syntax errors are incorrect
identation, typos, or incorrect
arguments
Because the inconsistent quotes, so Python throws
a SyntaxError
7. INDEX ERROR
• Index Error raised whenever attempting
to access an index that is outside the
bounds of a list
• If you try to access an item in a list
that doesn’t exist, you will get list
index out of range
• Python doesn’t want to access an item
that doesn’t exist.
8. Why Name Error Arise
Name Error is raised when you tried to use a variable,
method or function that is not initialized.
It also arise when you want to access local variable from
global
It can also happen because you forgot to use an appropriate
import statement before using additional functionality
NAME ERROR
9. KEY ERROR
Key Error is raised when
you try to access a key
that isn’t in a dictionary
Key Error also raised in
other places in Python’s
Standard Library, such
as in the zipfile module,
if an item is not found
in a ZIP archive
COMMON CASE
RARE CASE