본문 바로가기
DevLog/오류 해결 (Troubleshooting)

[Python] TypeError: 'type' object is not subscriptable

by Coding_WONI 2023. 9. 12.

코테 연습을 하는 과정에서 발생한 오류!

코테 특성상 어디 코드에서 발생하는 오류인지 모르기때문에 직접 찾아야 했습니다.

 

저의 경우는 

예약어를 변수 이름으로 사용하는 경우

maps 변수가 있지만 map으로 사용하여 발생한 오류였습니다

def solution(maps):
	answer = []
    """
    ...
    """
    map[x][y]	# map(X) / maps[O]
    
    """
    ...
    """
    return answer
class map(object)
 |  map(func, *iterables) --> map object
 |  
 |  Make an iterator that computes the function using arguments from
 |  each of the iterables.  Stops when the shortest iterable is exhausted.
 |  
 |  Methods defined here:
 |  
 |  __getattribute__(self, name, /)
 |      Return getattr(self, name).
 |  
 |  __iter__(self, /)
 |      Implement iter(self).
 |  
 |  __next__(self, /)
 |      Implement next(self).
 |  
 |  __reduce__(...)
 |      Return state information for pickling.
 |  
 |  ----------------------------------------------------------------------
 |  Static methods defined here:
 |  
 |  __new__(*args, **kwargs) from builtins.type
 |      Create and return a new object.  See help(type) for accurate signature.