I run the following code:
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()
but get the following error:
d=d.append(i)
AttributeError: 'NoneType' object has no attribute 'append'
Why is it happening? Please help to fix it.
dwith the return value ofd.append, which isNone, resulting in the error. You do not need to assign the return value oflist.appendto some variable.