On Sun, Apr 7, 2019 at 4:04 AM Dennis Lee Bieber <wlfr...@ix.netcom.com> wrote: > >output = "" > >for num in n: > > if (num % 3 == 0): output += "Fizz" > > if (num % 5 == 0): output += "Buzz" > > print(output or num) > > > You aren't initializing the output /inside/ the loop. > > Note that 0 is considered a false, so the if() become, in essence: if > false equal false...
Not sure the significance of this. Modulo between two integers will either return zero (if one is a multiple of the other) or a nonzero value (if there's some remainder). Comparing that value to zero will give back true if a multiple, or false if not, which is exactly what's wanted here. ChrisA -- https://mail.python.org/mailman/listinfo/python-list