반응형
호출할 수 없는 객체 호출
문제 코드:
number = 10
result = number()
오류 메시지:
TypeError: 'int' object is not callable
해결 방법: 여기서 number는 정수(int)이므로 함수처럼 호출할 수 없습니다. 변수 이름을 함수로 착각한 경우가 많습니다. 함수 호출이 아닌 변수 사용을 의도했다면, 괄호를 제거해야 합니다.
result = number
또는, 실제로 함수 호출을 의도한 것이라면, 올바른 함수를 사용해야 합니다.
def number():
return 10
result = number()
반응형
'파이썬 > 에러 디버깅' 카테고리의 다른 글
KeyError (0) | 2024.08.18 |
---|---|
IndexError (0) | 2024.08.18 |
TypeError: can't multiply sequence by non-int of type 'list' (0) | 2024.08.17 |
TypeError: can only concatenate str (not "int") to str (0) | 2024.08.17 |
NameError: name 'greet' is not defined (0) | 2024.08.10 |