I would like to be able to insert a line of code that counts the number of times the output is "watch".
Asked
Active
Viewed 1,208 times
-6
-
7Please post code as text. It makes it easier for people to help you by being able to copy-paste it. Also it seems you are aware of variables. Did you know you can do something like `x = x + 1`? If you start with `x = 0` you can count stuff – Tomerikoo Apr 05 '20 at 21:29
-
add a count variable and increment whenever the condition is watch and finally print it – coldy Apr 05 '20 at 21:31
-
You can calculate it arithmetically, there's no need to count. – Barmar Apr 05 '20 at 21:32
-
A simple counter maybe? Something like `i += 1` – JvdV Apr 05 '20 at 21:33
2 Answers
1
Try this one:
counter = 0
while Amzn > 1000:
counter+=1
print("Watch")
Amzn = Amzn - (Amzn*.0103)
else:
print("buy")
print(counter)

Gabio
- 9,126
- 3
- 12
- 32
0
i = 0
[...stuff...]
i += 1
print(f"Watch {i}")

Lydia van Dyke
- 2,466
- 3
- 13
- 25
-
It would be clearer for the OP (who seems to be a beginner) to show the actual `while` loop than `...stuff...`. – Gino Mempin Apr 05 '20 at 23:59