我运行以下代码:
import sys
def find_common(a,b,c):
d=[]
for i in a:
if i in b:
d=d.append(i)
for i in d:
if i not in c:
c=c.append(i)
print(c)
return c
if __name__ == '__main__':
a=[1,1,2,4]
b=[2,2,3,4]
c=[]
find_common(a,b,c)
sys.exit()
Run Code Online (Sandbox Code Playgroud)
但出现以下错误:
d=d.append(i)
AttributeError: 'NoneType' object has no attribute 'append'
Run Code Online (Sandbox Code Playgroud)
为什么会发生这种情况?请帮忙修复它。
| 归档时间: |
|
| 查看次数: |
19970 次 |
| 最近记录: |