for fizzbuzz in range(1,500):
if (fizzbuzz % 3==0 and fizzbuzz % 5==0:
print(fizzbuzz)
else:
print(not divisible)
Now, how to see how many fizzbuzz's are there with exact count.
CodePudding user response:
You simply need to update a counter. Adding to the code you've shown and properly indenting:
c = 0
for fizzbuzz in range(1,500):
if (fizzbuzz % 3==0 and fizzbuzz % 5==0:
print(fizzbuzz)
c = 1
else:
print(not divisible)
print(c)
Of course, you could also just increment your range by 15
, and start with 15
:
c = 0
for i in range(15, 500, 15):
print(fizzbuzz)
c = 1
print(c)