본문 바로가기
python

[error] TypeError: 'list' object cannot be interpreted as an integer

by Soo-minJeon 2022. 5. 12.

list를 숫자처럼 사용해서 생긴 오류.

 

나 같은 경우에는

list = [1,2,3,4]
for i in range(list): # 오류 발생
	print(list)

 

이런 식으로 list를 range안에 바로 넣어서 생긴 오류였다.

len(list) 로 고쳐써주었다.

 

list = [1,2,3,4]
for i in range(len(list)): # 오류 수정
	print(list)