📌  相关文章
📜  如何仅打印 for 循环 pyhton 的最终迭代 - Python 代码示例

📅  最后修改于: 2022-03-11 14:46:06.082000             🧑  作者: Mango

代码示例1
prices = [10, 20, 30]
total = 0
for price in prices:
    total += price
    #print(f'total: {total}') will give all iterations in order
print(f'total: {total}') #make sure to print outside of loop for 
#only final iteration to print