Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def fizzbuzz(number): # the function should contain only one parameter
- for num in range(1, (number + 1)): # signifies numbers from 1 to the number given
- if num%3==0 and num%5==0: # number divisible by both 3 and 5
- print("FizzBuzz") # prints "FizzBuzz" if number is divsible by both 3 and 5
- elif num%5==0: # number divisible by only 5
- print("Buzz") # prints "Buzz" if number is divisible by only 5
- elif num%3==0: # number divisible by only 3
- print("Fizz") # prints "Fizz" if number is divisible by only 3
- else:
- print(num) # prints the number if number is neither divisible by 3 nor 5
- fizzbuzz(30) # Example the argument must be a positive whole number
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement