-
-
Save tmodrzynski/d099014e05d3b4bb25a4 to your computer and use it in GitHub Desktop.
Python developer - coverage question easy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def fizzbuzz(count): | |
"""FizzBuzz implementation | |
Returns list of output messages. | |
""" | |
if not isinstance(count, int): | |
raise TypeError('count must be an integer') | |
if count < 1 or count > 1000: | |
raise ValueError('count must be between 1 and 1000') | |
results = [] | |
for num in xrange(1, count+1): | |
if num % 3 == 0 and num % 5 == 0: | |
results.append('FizzBuzz') | |
elif num % 3 == 0: | |
results.append('Fizz') | |
elif num % 5 == 0: | |
results.append('Buzz') | |
else: | |
results.append(str(num)) | |
return results |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment