TypeError: 'list' object cannot be interpreted as an integer 해결 문자열데이터를 정수형처럼 사용했을때 나는 오류이다. 나는 아래의 코드에서 오류가 났다. def solution(arr1, arr2): answer = [[]*len(arr1)]*len(arr1[0]) for i in range(arr1): for j in range(arr1[0]): answer[i][j] = arr1[i][j] + arr2[i][j] return answer 다시보니 len()붙여주는 걸 깜박하고 그대로 써버려서 수정해줬다. 오류를 고쳐라! 2023.06.14
TypeError: 'str' object does not support item assignment TypeError: 'str' object does not support item assignment은 문자열(string)은 아이템 수정이 불가능하다는 이야기 이다. 즉, 바꾸고 싶은 변수의 자료형을 str이 아니라 list등으로 바꿔주면 된다 오류를 고쳐라! 2023.06.13
ZeroDivisionError: integer division or modulo by zero 해결 ZeroDivisionError: integer division or modulo by zero 해결 이 오류는 python에서 0으로 나누는 경우가 생겼을때 생긴다. 나의 경우 아래와 같은 코드를 사용했을 때 나왔다. def solution(left, right): answer = 0 for i in range(left,right+1): result = 0 #바로 이 아랫줄!! for j in range(i+1): if i%j == 0: result+=1 if result%2 == 0: answer+= i else: answer -= i return answer 해결법은 간단하게 1 부터 나눌 수 있도록 바꿔주면 된다. def solution(left, right): answer = 0 for i in.. 오류를 고쳐라! 2023.06.13
Type Error: list indices must be integers or slices, not tuple Type Error: list indices must be integers or slices, not tuple 오류가 나타났다... 나타난 문장은 바로 Type Error: list indices must be integers or slices, not tuple if data[nx,ny]==0 and check[nx,ny] == 0: 이것.. 받아올때는 data = [list(map(int, input().split()) for _ in range(n))] 가독성을 위해 한 줄로 된 이 코드를 사용했다. 난 튜플 사용안했는데 왜... 라고 생각했으나 if data[nx,ny]접근이 아니라 data[nx][ny]였다....킥....해결완료.. 오류를 고쳐라! 2023.06.06
TypeError: can only concatenate str (not "int") to str 해결 data = input() first = data[0] second = int(data[1]) count = 0 if 'a' 오류를 고쳐라! 2023.04.12