Error decoder
Paste an error message into the search to learn why it appeared and how to fix it.
Common errors
PythonNameError: name 'nmae' is not definedUnknown name
Why: You used a variable that does not exist: a typo, or it was not created yet.
How to fix: Check the spelling and create the variable before using it.
name = "Ola"
print(nmae)name = "Ola"
print(name)PythonTypeError: can only concatenate str (not "int") to strString plus number
Why: The `+` operator cannot join a string with a number.
How to fix: Convert the number with `str()` or use an f-string.
print("Age: " + 5)print("Age: " + str(5))PythonIndentationError: expected an indented block after 'if' statement on line 2Missing indentation
Why: The body of a block after `if` must be indented.
How to fix: Indent the lines inside the block (4 spaces).
x = 1
if x:
print(x)x = 1
if x:
print(x)PythonSyntaxError: '(' was never closedUnclosed parenthesis
Why: A parenthesis was opened but never closed.
How to fix: Add the closing parenthesis `)`.
print("hi"print("hi")PythonIndexError: list index out of rangeIndex out of range
Why: A list of three items has indexes 0, 1, 2. Index 3 does not exist.
How to fix: Use an index from 0 to `len(a) - 1`, or `a[-1]` for the last item.
a = [1, 2, 3]
print(a[3])a = [1, 2, 3]
print(a[2])PythonKeyError: 'b'Missing key
Why: The dictionary has no key "b".
How to fix: Check the key with `in` or read it with the `get` method.
d = {"a": 1}
print(d["b"])d = {"a": 1}
print(d.get("b", 0))JavaScriptReferenceError: total is not definedVariable not declared
Why: You use a variable that was never declared.
How to fix: Declare it with `let` or `const` before using it.
console.log(total);const total = 10;
console.log(total);JavaScriptTypeError: Assignment to constant variable.Changing a constant
Why: The variable is declared with `const` and cannot be reassigned.
How to fix: Use `let` if the value must change.
const n = 1;
n = 2;let n = 1;
n = 2;JavaScriptTypeError: Cannot read properties of undefined (reading 'name')Property of undefined
Why: You read `.name` from `undefined`: there is no object.
How to fix: Make sure the object exists, or use `user?.name`.
const user = undefined;
console.log(user.name);const user = undefined;
console.log(user?.name);JavaScriptTypeError: x is not a functionNot a function
Why: You call with `()` a value that is not a function.
How to fix: Call only functions, and use numbers or strings without parentheses.
const x = 5;
x();const x = () => 5;
x();JavaScriptSyntaxError: Unexpected token ';'Unexpected token
Why: The array was not closed with `]`, so `;` appeared where it was not expected.
How to fix: Close the brackets properly.
const a = [1, 2;const a = [1, 2];JavaScriptReferenceError: Cannot access 'x' before initializationUsed before declaration
Why: A `let` or `const` variable is read before the line that creates it.
How to fix: Move the declaration above the first use.
console.log(x);
let x = 1;let x = 1;
console.log(x);PHPWarning: Undefined variable $nameUndefined variable
Why: Nobody created `$name`, or the name has a typo.
How to fix: Assign a value before using it.
<?php
echo $name;<?php
$name = "Ola";
echo $name;PHPParse error: syntax error, unexpected token "echo", expecting "," or ";"Missing semicolon
Why: The previous line does not end with `;`.
How to fix: End every statement with `;`.
<?php
echo "hi"
echo "x";<?php
echo "hi";
echo "x";PHPWarning: Undefined array key 5Undefined array key
Why: The array has no element with key 5.
How to fix: Check the key with `isset` or the `??` operator.
<?php
$a = [1];
echo $a[5];<?php
$a = [1];
echo $a[5] ?? 0;Godeclared and not used: xUnused variable
Why: Go does not allow a local variable that is never used.
How to fix: Use the variable or remove it.
package main
func main() {
x := 5
}package main
import "fmt"
func main() {
x := 5
fmt.Println(x)
}Go"os" imported and not usedUnused import
Why: The package is imported but never used in the code.
How to fix: Remove the unneeded import.
package main
import (
"fmt"
"os"
)
func main() {
fmt.Println("hi")
}package main
import "fmt"
func main() {
fmt.Println("hi")
}Gocannot use "5" (untyped string constant) as int value in variable declarationType mismatch
Why: A string is assigned to an `int` variable.
How to fix: Write the number without quotes, or convert the string with `strconv.Atoi`.
package main
import "fmt"
func main() {
var n int = "5"
fmt.Println(n)
}package main
import "fmt"
func main() {
var n int = 5
fmt.Println(n)
}Javaerror: incompatible types: String cannot be converted to intIncompatible types
Why: A string is put into an `int` variable.
How to fix: Write the number without quotes, or use `Integer.parseInt("5")`.
public class Main {
public static void main(String[] args) {
int x = "5";
System.out.println(x);
}
}public class Main {
public static void main(String[] args) {
int x = Integer.parseInt("5");
System.out.println(x);
}
}Javaerror: cannot find symbolCannot find symbol
Why: The compiler does not know the variable `totl`: a typo or it was not declared.
How to fix: Fix the name or declare the variable.
public class Main {
public static void main(String[] args) {
int total = 5;
System.out.println(totl);
}
}public class Main {
public static void main(String[] args) {
int total = 5;
System.out.println(total);
}
}Javaerror: missing return statementMissing return
Why: When the condition is false, the method reaches its end and returns nothing.
How to fix: Add a `return` for every path.
public class Main {
static int twice(int n) {
if (n > 0) {
return n * 2;
}
}
public static void main(String[] args) {
System.out.println(twice(2));
}
}public class Main {
static int twice(int n) {
if (n > 0) {
return n * 2;
}
return 0;
}
public static void main(String[] args) {
System.out.println(twice(2));
}
}Cwarning: implicit declaration of function 'square' [-Wimplicit-function-declaration]Function not declared
Why: `square` is called but is neither defined nor declared above.
How to fix: Define the function before `main` or add its prototype.
#include <stdio.h>
int main(void) {
int n = square(4);
printf("%d\n", n);
return 0;
}#include <stdio.h>
int square(int x) { return x * x; }
int main(void) {
int n = square(4);
printf("%d\n", n);
return 0;
}Cerror: expected ';' before 'return'Missing semicolon
Why: The `printf` line does not end with `;`.
How to fix: Put `;` at the end of the statement.
#include <stdio.h>
int main(void) {
printf("hi\n")
return 0;
}#include <stdio.h>
int main(void) {
printf("hi\n");
return 0;
}Cerror: 'm' undeclared (first use in this function)Undeclared variable
Why: There is no variable `m`: a typo or it was never created.
How to fix: Declare the variable or fix the name.
#include <stdio.h>
int main(void) {
int n = 5;
printf("%d\n", m);
return 0;
}#include <stdio.h>
int main(void) {
int n = 5;
printf("%d\n", n);
return 0;
}No such error yet. Write to us and we will add it.
More in the Lab
Errors are part of learning
Each requirement in the courses has a hint, and you can try as often as you like.