+ 1

can some one help me as to why my fizz buzz is not working. (python)

im using python, i wanted to only use one statement for "fizz" and one for "buzz" and use them both when applied. rather than a third for "fizzbuzz" itself. (if not familiar fizz buzz is a game where you count divisible by 3 you say fizz, divisible by 5 you say buzz and divisible by both you say "fizzbuzz") the dividable by 5 works, and by 3 and 5 work. but for some reason 3 isn't working. effit=0 while effit < 100: output = "" effit+=1 if (effit % 3 == 0 ): output += ("fizz") if (effit % 5 == 0): output += ("buzz") else: output = effit print(output)

16th Jun 2020, 11:25 PM
Dillon Flannery
Dillon Flannery - avatar
4 Réponses
+ 6
when effit becomes 3 output contains fizz but again condition for effit%5 is checked and since it is false output now contains 3 and 3 is printed instead of fizz
16th Jun 2020, 11:44 PM
Abhay
Abhay - avatar
+ 1
16th Jun 2020, 11:53 PM
Vasile Eftodii
Vasile Eftodii - avatar
0
thanks, ima keep working on it. might need a new approach.
17th Jun 2020, 12:23 AM
Dillon Flannery
Dillon Flannery - avatar
- 2
excuse me, where did u found this exercice on the pc ? i have those exercices on my phone, but not on the pc (
18th Oct 2020, 5:56 PM
Bogdan Dmytrenko