+ 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)
4 Answers
+ 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
+ 1
You have an error in the "if .. elif .. else" statement.
https://www.tutorialspoint.com/JUMP_LINK__&&__python__&&__JUMP_LINK/python_if_else.htm
0
thanks, ima keep working on it. might need a new approach.
- 2
excuse me, where did u found this exercice on the pc ? i have those exercices on my phone, but not on the pc (