name 'List' is not defined

Tasic·2021년 1월 24일

증상

leetcode에서 문제를 풀기 위해 vs code로 소스 복사해서 빌드했는데, 발생한에러

해결방법

해결법은 간단하다.
from typing import List

여담

python3.9 부터 내장 컬렉션 형을 제네릭으로 사용 가능함.

3.8 - 에러 발생

3.9 - 정상 실행

Reference

파이썬 3.9의 새로운 기능
NameError: name 'List' is not defined - StackOverflow

profile
블로그 옮겼습니다 (https://jotasic.github.io)

0개의 댓글