python使用list, 时总是报错

Traceback (most recent call last):

File "<stdin>", line 1, in <module>

TypeError: 'list' object is not callable

刚开始学习python的时候,可能会由于命名的不注意,导致也方法一直用不了,原因是在声明变量对的时候和python内置方法冲突了,导致方法被重新定义了,这样一来,方法自然也就不存在了

解决办法:先复制个其他的list

c = list.copy()

然后清空list列表名的列表

list.clear()

再次使用list( ),成功声明并赋值

l1 = list(range(10))