Every line of 'fizzbuzz program in python using function' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.
4 def fizz_buzz(): 5 for i in range(1, 101): 6 if i % 3 == 0 and i % 5 == 0: 7 print("FizzBuzz") 8 elif i % 3 == 0: 9 print("Fizz") 10 elif i % 5 == 0: 11 print("Buzz") 12 else: 13 print(i)
Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code
27 def test_fizz_buzz(): 28 expected = [ 29 "1", 30 "2", 31 "Fizz", 32 "4", 33 "Buzz", 34 "Fizz", 35 "7", 36 "8", 37 "Fizz", 38 "Buzz", 39 "11", 40 "Fizz", 41 "13", 42 "14", 43 "FizzBuzz" 44 ] 45 assert fizz_buzz(15) == expected