请问下面两段代码有什么区别呢
code 1
a = [1,2,3]
for x in a:
if x < 2:
a.insert(0,5);
code 2:
a = [1,2,3]
for x in a[:]:
if x < 2:
a.insert(0,5);
请问下面两段代码有什么区别呢
code 1
a = [1,2,3]
for x in a:
if x < 2:
a.insert(0,5);
code 2:
a = [1,2,3]
for x in a[:]:
if x < 2:
a.insert(0,5);