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)]
def fizz_buzz(n):return ['FizzBuzz' if (i % 15 == 0) else 'Fizz' if(i % 3 == 0) else 'Buzz' if(i % 5 == 0) else i for i in range(1,n)]- 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)]
actual = list(fizz_buzz(17)) expected = [1, 2, 'Fizz', 4, 'Buzz', 'Fizz', 7, 8, 'Fizz', 'Buzz', 11, 'Fizz', 13, 14, 'FizzBuzz', 16] test.assert_equals(actual, expected)
- actual = list(fizz_buzz(17))
- expected = [1, 2, 'Fizz', 4, 'Buzz', 'Fizz', 7, 8, 'Fizz', 'Buzz', 11, 'Fizz', 13, 14, 'FizzBuzz', 16]
Test.assert_equals(actual, expected)- test.assert_equals(actual, expected)