Ad

Boolean in Python evaluates to integer.

Code
Diff
  • def fizz_buzz(m):
        return ["Fizz"*(n%3==0)+"Buzz"*(n%5==0)  if (n%3==0 or n%5==0) else n for n in range(1,m)]
        
    • def fizz_buzz(m):
    • return ["Fizz"*int(n%3==0)+"Buzz"*int(n%5==0) if (n%3==0 or n%5==0) else n for n in range(1,m)]
    • return ["Fizz"*(n%3==0)+"Buzz"*(n%5==0) if (n%3==0 or n%5==0) else n for n in range(1,m)]