1/6
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
SyntaxError
When the Python interpreter parses your code and finds incorrect code that does not conform to the syntax rules
Unclosed strings
Indentation issues
Misusing the assignment operator (=)
Misspelling Python keywords
Missing brackets, parentheses, or braces
IdentationError
When there's an indentation issue in your code. Common causes include mixing tabs with spaces, incorrect spacing, incorrectly nested blocks, or whitespace at the beginning of a statement or file.
NameError
If you attempt to use an identifier that hasn't been defined or might be out of scope. Other potential causes of a NameError include referencing a variable before its assignment or misspelling an identifier:
ValueError
You've entered invalid input to a function and it doesn't make sense to process it.
Function received an argument of the correct data type; however, the value itself is invalid. For example, the int()
method accepts only integer string like "42"
, and passing something like "forty-two"
will yield a ValueError
:
TypeError
You've tried to perform an operation on two types and neither of the types understand what to do with the other.
You are performing an operation that is not supported or appropriate for the object data type. For example, trying to divide a string with an integer
Can also occur in situations like trying to loop over a non-iterable (such as a float or integer) or using incorrect argument types for built-in methods (like passing an integer to len(), which expects an iterable). Furthermore, calling a function with fewer arguments than required or comparing different data types can also lead to a TypeError
IndexError
When you attempt to access an index in a sequence, such as a list, tuple, or string, and it is outside the valid range. For instance, trying to access index 4 in a list with only three elements
AttributeError
You've tried to access an attribute of an object that doesn't exist.
When there's an attempt to access or utilize an attribute that an object or class doesn't possess. For instance,
-If we try to access the append() method on an integer value, we can get an AttributeError:
Output: As int object doesn't contain any append() method, it will give out AttributeError.