Python Error Types

0.0(0)
Studied by 1 person
call kaiCall Kai
Locked
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/15

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 6:00 PM on 5/8/25
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

16 Terms

1
New cards

Syntax Error

Occurs when Python encounters code that violates its syntax rules.

2
New cards

Example of Syntax Error

print("Hello World") - The closing quote is missing.

3
New cards

Indentation Error

Occurs when the code is not properly indented, breaking Python’s strict indentation rules for blocks.

4
New cards

Example of Indentation Error

for i in range(5): print(i) - The print statement should be indented under the for loop.

5
New cards

Name Error

Happens when a variable or function is used before it is defined.

6
New cards

Example of Name Error

print(myvariable) - myvariable is not defined before it is used.

7
New cards

Type Error

Raised when an operation is performed on incompatible data types.

8
New cards

Example of Type Error

result = 5 + "10" - Cannot add an integer (5) and a string ("10").

9
New cards

Attribute Error

Occurs when a non-existent attribute is accessed on an object.

10
New cards

Example of Attribute Error

text = "Hello"; text.append(" World") - Strings do not have an append() method.

11
New cards

Value Error

Happens when a function receives an argument of the correct type but an inappropriate value.

12
New cards

Example of Value Error

number = int("Hello") - The string "Hello" cannot be converted to an integer.

13
New cards

Index Error

Occurs when trying to access an element of a list or tuple that is out of range.

14
New cards

Example of Index Error

mylist = [1, 2, 3]; print(mylist[3]) - The list has only three elements (indices 0, 1, and 2).

15
New cards

Import Error

Occurs when an imported module cannot be found or cannot be loaded.

16
New cards

Example of Import Error

import nonexistentmodule - The specified module does not exist.