Python 如何附加For循环中所有结果的列表?

Python 如何附加For循环中所有结果的列表?,python,list,loops,printing,append,Python,List,Loops,Printing,Append,我正努力让我的功能发挥作用。这是它的基础: #for example: data=[(b),(c),(d),(e)] results=[] for x in data: #this goes through each row of the data # body_code executes. This part is mostly just changing types, etc a=final_body_code results.append(a) print res

我正努力让我的功能发挥作用。这是它的基础:

#for example:
data=[(b),(c),(d),(e)]

results=[]
for x in data: #this goes through each row of the data
    # body_code executes. This part is mostly just changing types, etc
    a=final_body_code
    results.append(a)
print results

#output should be: results=[(b),(c),(d),(e)] #After changing types of b,c,d,e etc.

#The body of the code does not matter at this point, it's just the appending which i'm
#struggling with. 

然而,当我这样做时,它似乎并没有在结果列表中添加一个。说到python,我是个新手,所以请帮帮我

我想这是你愿意做的

data=[(b),(c),(d),(e)]

results=[]

for x in data:
    results.append(x)

print results

您应该添加示例

也许您在
a=final\u body\u code
中遇到了一些问题,结果是
None

但是,对@Mrinal Wahal answer稍作改进,使用:


为我们提供输入/预期输出?首先,什么是
->
?这应该是一个评论吗?其次,您确定
数据
不是空的还是无的?第三,你说它穿过每一行是什么意思?还有很多问题。。提供更多详细信息。
打印出
数据
,并确保这些数据不为空(也称为
)。
data
是嵌套列表吗?给我们一个。您的问题没有包含足够的信息来诊断问题。请确保已到达内部for循环。在循环中放入print语句。如果
data
为空,则结果将为空,因为循环将被跳过
results = [final_body_code(i) for i in data]
data = [b, c, d, e]

results = []

results.extend(final_body_code(i) for i in data)

return results