想知道为什么方法1是正确的,方法2是错误的.
方法一:
def remove_duplicates(x):
y = []
for n in x:
if n not in y:
y.append(n)
return y
Run Code Online (Sandbox Code Playgroud)
方法2:
def remove_duplicates(x):
y = []
for n in x:
if n not in y:
y = y.append(n)
return y
Run Code Online (Sandbox Code Playgroud)
我不明白为什么第二种方法会返回错误的答案?
python ×1