오류 해결 사전
코드를 돌렸더니 빨간 글이 나왔나요? 오류 글에서 맨 아래 줄을 찾아 여기서 골라 보세요. 쪽마다 오류의 뜻, 자주 나는 원인, 틀린 코드와 고친 코드가 있고, 둘 다 그 자리에서 실행해 볼 수 있어요.
파이썬
AttributeError: 'NoneType' object has no attribute 'append'None인 값에 점을 찍어 무언가를 하려 했을 때EOFError: EOF when reading a line더 읽을 입력이 없는데 input()을 불렀을 때IndentationError: expected an indented block들여쓰기가 빠졌거나 칸 수가 맞지 않을 때IndexError: list index out of range리스트에 없는 번호의 칸을 꺼내려 했을 때KeyError: 'kiwi'딕셔너리에 없는 키로 값을 꺼내려 했을 때NameError: name 'x' is not defined만든 적 없는 이름을 썼을 때SyntaxError: invalid syntax파이썬 문법에 맞지 않는 줄이 있을 때TypeError: can only concatenate str (not "int") to str문자열에 + 로 수를 붙이려 했을 때TypeError: add() missing 1 required positional argument: 'b'함수가 받기로 한 값보다 적게 넘겼을 때TypeError: 'int' object is not callable함수가 아닌 값 뒤에 소괄호를 붙였을 때TypeError: 'int' object is not iterable하나씩 꺼낼 수 없는 값을 for 문에 넣었을 때TypeError: 'int' object is not subscriptable대괄호로 꺼낼 수 없는 값에 [ ]를 썼을 때TypeError: unsupported operand type(s) for +: 'int' and 'str'계산할 수 없는 두 값을 + - * / 로 묶었을 때ValueError: invalid literal for int() with base 10: '3 5'정수로 바꿀 수 없는 글자를 int()에 넣었을 때ValueError: not enough values to unpack (expected 2, got 1)변수 개수보다 값이 적게 들어왔을 때ZeroDivisionError: division by zero어떤 수를 0으로 나누려 했을 때
C언어
warning: control reaches end of non-void function [-Wreturn-type]값을 돌려줘야 하는 함수가 return 없이 끝날 수 있을 때error: expected ‘;’ before ‘return’문장 끝의 세미콜론(;)을 빠뜨렸을 때warning: format ‘%d’ expects argument of type ‘int *’, but argument 2 has type ‘int’printf·scanf의 서식(%d, %f ...)과 넘긴 값의 타입이 다를 때warning: implicit declaration of function ‘strlen’컴파일러가 처음 보는 이름의 함수를 불렀을 때error: lvalue required as left operand of assignment= 왼쪽에 값을 넣을 수 없는 것이 왔을 때(흔히 ==를 =로 씀)Segmentation fault (core dumped)프로그램이 건드리면 안 되는 메모리를 읽거나 쓰려 했을 때error: ‘sum’ undeclared (first use in this function)선언하지 않은 이름의 변수를 썼을 때undefined reference to `main'부른 함수의 본체를 어디에서도 찾지 못했을 때