python-for循环

来源:互联网 发布:淘宝如何报名试用 编辑:程序博客网 时间:2024/05/16 11:35

for循环用于对集合进行迭代处理,标准语法:

for value in collection

       #对value进行一些处理

if ...continue

a=[1,2,None,4,None,5]

total = 0
for value in a:
    if value is None:
        continue
    total = total+value

print total
12

 

 

0 0