Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ```python
- """ FizzBuzz
- Rules:
- Make a function that prints a range of numbers (1-100 by default)
- If the number is:
- a) a multiple of 5, print 'Fizz'
- b) a multiple of 7, print 'Buzz'
- c) a multiple of 15, print 'FizzBuzz'
- Otherwise, print the number.
- Example output (1-20):
- 1
- 2
- 3
- 4
- Fizz
- 6
- Buzz
- 8
- 9
- Fizz
- 11
- 12
- 13
- Buzz
- FizzBuzz
- 16
- 17
- 18
- 19
- Fizz
- """
- def fizzbuzz(iterations: int = 100):
- for index in range(1, iterations+1):
- if not index % 15:
- print('FizzBuzz')
- elif not index % 5:
- print('Fizz')
- elif not index % 7:
- print('Buzz')
- else:
- print(index)
- fizzbuzz()
- ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement