https://github.com/famousdraw

NameError: name 'List' is not defined

leetcode 刷题的时候,遇到下列错误。
1 class Solution: ----> 2 def kidsWithCandies(self, candies: List[int], extraCandies: int) -> List[bool]: 3 #遍历所有的孩子 4 #增加糖果数量 5 #查看是否是最多的糖果,是,if_max,增加True NameError: name 'List' is not defined


在最前部增加:
from typing import List
解决问题。

 

如果你认为文章有用,欢迎打赏。

 

posted on 2020-06-01 15:30  红色MINI  阅读(2488)  评论(0编辑  收藏  举报

导航