Error Glossary

Every programming error explained in plain English — what it means, why it happens, and exactly how to fix it.

Python Errors
SyntaxError
PythonBeginner
Python cannot even read your code because it is written incorrectly. Like a sentence with missing punctuation.
Most common cause: Missing colon (:) after for, if, while, def, or class statements.
SyntaxError: expected ':' (line 3)
Fix: Add the colon at the end of the line. Every code block in Python starts with a colon.
Like writing a sentence without a full stop — the reader (Python) cannot tell where one thought ends and the next begins.
Try in CodeDost →
TypeError
PythonBeginner
You performed an operation on the wrong type of data. Python cannot add a number to a string the same way it cannot add salt to a cup of tea that has already been sealed.
Most common cause: Trying to concatenate (join) a string with an integer using + without converting first.
TypeError: can only concatenate str (not "int") to str
Fix: Use str() to convert the integer to a string first: "Age: " + str(age)
Trying to add a number directly to a sentence. You have to "translate" the number to words first.
Try in CodeDost →
IndexError
PythonBeginner
You tried to access a position in a list that does not exist. Lists start at position 0, not 1.
Most common cause: Using range(len(list) + 1) instead of range(len(list)), going one position too far.
IndexError: list index out of range
Fix: A list with 5 items has indices 0, 1, 2, 3, 4. Index 5 does not exist. Use range(len(list)) not range(len(list)+1).
Like asking for seat number 6 in a rickshaw that only has 5 seats. The seat does not exist.
Try in CodeDost →
NameError
PythonBeginner
You used a variable or function name that Python has never seen before. Either you forgot to define it, or you spelled it wrong.
Most common cause: Typo in a variable name, or using a function before defining it.
NameError: name 'squareroot' is not defined
Fix: Import the correct module (import math) or use the correct function name (math.sqrt not squareroot).
Calling someone by the wrong name. Python looks through its contacts list but cannot find anyone called 'squareroot'.
Try in CodeDost →
NoneType Error
PythonIntermediate
You tried to use the result of a function, but the function returned nothing (None). None is Python's way of saying "this function produced no result."
Most common cause: A function that searches for something but returns nothing when it cannot find it.
TypeError: 'NoneType' object is not subscriptable
Fix: Add a check: if result is not None: before using the result. Or add a return statement for the not-found case.
You ordered biryani from a dukaan (shop), but the shop was closed. The delivery returned nothing. You still tried to eat the empty bag.
Try in CodeDost →
ImportError
PythonBeginner
Python cannot find the module (library) you are trying to import. Either it is not installed or the name is wrong.
Most common cause: Forgetting to install a package (pip install package-name) or typo in the module name.
ModuleNotFoundError: No module named 'requests'
Fix: Run pip install requests in your terminal first, then import it in your code.
Trying to call a phone number that is not in the phone book. You need to add it first (install it), then call (import it).
Try in CodeDost →
ValueError
PythonBeginner
The data type is correct but the actual value is not valid for this operation. Like asking someone their age and they answer "blue."
Most common cause: Trying to convert a non-numeric string to int: int("hello") or int("12abc").
ValueError: invalid literal for int() with base 10: 'hello'
Fix: Validate the input first. Use try/except to catch invalid values, or check if the string is numeric before converting.
Filling in a form that asks for your age and writing "old." The form accepts text (correct type) but "old" is not a valid age number.
Try in CodeDost →
JavaScript Errors
ReferenceError
JavaScriptBeginner
You tried to use a variable that has not been declared. JavaScript cannot find it anywhere in scope.
Most common cause: Typo in variable name, or using a variable before declaring it with let/const/var.
ReferenceError: myVaraible is not defined
Fix: Declare the variable first with let, const, or var. Check for typos — JavaScript is case-sensitive.
Calling a person's name in a room where they have not arrived yet. Nobody responds because they are not there.
Try in CodeDost →
Scope Bug (let vs var)
JavaScriptIntermediate
A variable declared with let inside a block (if, for) only exists inside that block. Outside the block, the outer variable is used instead, causing wrong results with no error message.
Most common cause: Declaring let discountRate inside an if block when you meant to modify the outer discountRate.
// Expected: 6800 (15% discount) | Got: 7600 (5% discount)
Fix: Do not redeclare the variable inside the block. Just assign: discountRate = 0.15 (without let).
Like having two registers at a dukaan with the same name. The one inside the back room is different from the one at the front counter.
Try in CodeDost →
Async/Await Error
JavaScriptAdvanced
fetch() does not return data — it returns a Promise (a future delivery). Without await, your code reads the Promise object instead of the actual data.
Most common cause: Calling fetch() without await, or .json() without await. Both return Promises, not values.
TypeError: response.json is not a function | Student Name: undefined
Fix: Add async to your function and await before fetch() and before .json(). Both steps need await.
Ordering chai and immediately looking into an empty cup before it has been made. You need to wait (await) for the chai to arrive.
Try in CodeDost →
Java Errors
NullPointerException
JavaIntermediate
You tried to call a method or access a property on an object that is null. Null means "nothing" — you cannot do anything with nothing.
Most common cause: A method that should return an object returns null instead, and you use the result without checking.
NullPointerException at grade.toUpperCase()
Fix: Always add a null check before using a returned value: if (grade != null) { grade.toUpperCase(); }
Trying to squeeze juice from a glass that does not exist. You need to create the glass (return a value) before you can use it.
Try in CodeDost →
Missing Return Statement
JavaIntermediate
Your method promises to return a value (String, int, etc.) but there is a code path where it returns nothing. Java requires every possible path to return a value.
Most common cause: if-else chain that covers some cases but misses the else case entirely.
error: missing return statement
Fix: Add a final return statement outside all if blocks that handles the default case: return "F"; or return null;
A waiter who has a response for "Chai", "Coffee", and "Juice" but freezes completely if you order water. Every order needs an answer.
Try in CodeDost →
C++ Errors
Segmentation Fault
C++Beginner
Your program tried to read or write memory that does not belong to it. This almost always means accessing an array at an index that does not exist.
Most common cause: Using i <= 5 instead of i < 5 when the array has 5 items (indices 0 through 4).
Segmentation fault (core dumped)
Fix: Change <= to < in your loop condition. int marks[5] means indices 0,1,2,3,4 — not 0,1,2,3,4,5.
Trying to enter house number 6 in a street that only has houses numbered 1 through 5. That address does not exist — the OS stops you.
Try in CodeDost →