result = 0
for value in [14, 1, 33, 9, 25, 17]:
result = result + 1
print(result)
So the result is 6. But I cant seem to understand why? Like what is actually going on logically to get to the output "6"?
它基本上定义了一个赋值为 0 的变量result
,然后在 for 循环中,它循环遍历列表[14, 1, 33, 9, 25, 17]
,其中有 6 个项目,在每次迭代时分配value
列表中的下一个值并在 6 次迭代后递增result
, result
递增 6 次
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.