【发布时间】:2015-07-15 01:47:19
【问题描述】:
我写了如下代码sn-p:
origilist = [6, 252, 13, 10]
decilist = list(xrange(256))
def yielding(decilist, origilist):
half_origi = (len(origilist)/2)
for n in decilist:
yield origilist[:half_origi] + n + origilist[half_origi:]
for item in yielding(decilist, origilist):
print item
当我运行我得到的代码时:
yield origilist[:half_origi] + n + origilist[half_origi:]
TypeError: can only concatenate list (not "int") to list
有没有在特定索引中将整数连接到另一个列表?
感谢您的回答
【问题讨论】:
-
append、[]+[]等
标签: list python-2.7 for-loop integer