Error messages, explained
Did your code stop with an error? Find the last line of the error message and pick it below. Each page explains what the error means and its common causes, with wrong code and fixed code side by side. You can run both right on the page.
Python
AttributeError: 'NoneType' object has no attribute 'append'When you use a dot on a value that is actually NoneEOFError: EOF when reading a lineWhen input() is called but there is no input left to readIndentationError: expected an indented blockWhen indentation is missing or the spaces do not line upIndexError: list index out of rangeWhen you ask for an index the list does not haveKeyError: 'kiwi'When you look up a key the dictionary does not haveNameError: name 'x' is not definedWhen you use a name that was never createdSyntaxError: invalid syntaxWhen a line does not follow Python's syntaxTypeError: can only concatenate str (not "int") to strWhen you try to attach a number to a string with +TypeError: add() missing 1 required positional argument: 'b'When you pass fewer values than the function expectsTypeError: 'int' object is not callableWhen you put parentheses after a value that is not a functionTypeError: 'int' object is not iterableWhen you loop over a value that cannot give items one by oneTypeError: 'int' object is not subscriptableWhen you use [ ] on a value you cannot index intoTypeError: unsupported operand type(s) for +: 'int' and 'str'When you join two values with + - * / that cannot be calculated togetherValueError: invalid literal for int() with base 10: '3 5'When you give int() text that cannot become an integerValueError: not enough values to unpack (expected 2, got 1)When fewer values come in than you have variablesZeroDivisionError: division by zeroWhen you try to divide a number by 0
C
warning: control reaches end of non-void function [-Wreturn-type]A function that should return a value can end without a returnerror: expected ‘;’ before ‘return’You left out the semicolon (;) at the end of a statementwarning: format ‘%d’ expects argument of type ‘int *’, but argument 2 has type ‘int’A printf or scanf format (%d, %f ...) doesn't match the type of the value you passedwarning: implicit declaration of function ‘strlen’You called a function whose name the compiler has not seen yeterror: lvalue required as left operand of assignmentThe left side of = is something you can't store a value in (often = typed for ==)Segmentation fault (core dumped)Your program tried to read or write memory it must not toucherror: ‘sum’ undeclared (first use in this function)You used a variable name that has not been declaredundefined reference to `main'The body of a function you called can't be found anywhere