【发布时间】:2018-08-07 10:15:00
【问题描述】:
things="pen pencil apple mango litchi grapes pear song music"
stuff=things.split(" ")
items=["a","b","c","d"]
for word in items:
next_one=items.pop()
stuff.append(next_one)
print(stuff)
当我运行此代码时,结果列表显示只有最后两个元素是从项目中附加的。为什么不附加所有元素?
【问题讨论】:
-
stuff.append(word)删除next_one=items.pop()
标签: python-3.x list for-loop