如何计算python中while循环的输出?

问题描述 投票:-5回答:2

我希望能够插入一行代码,对输出为“ watch”的次数进行计数。

This is the picture of my current code

python while-loop count output
2个回答
0
投票
i = 0

[...stuff...]

i += 1
print(f"Watch {i}")

0
投票

尝试这个:

counter = 0
while Amzn > 1000:
    counter+=1
    print("Watch")
    Amzn = Amzn - (Amzn*.0103)
else:
    print("buy")
print(counter)
© www.soinside.com 2019 - 2024. All rights reserved.