How to use 'fizzbuzz program in python using function' in Python

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.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
4def 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)
27def 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

Related snippets