Created
July 13, 2020 03:12
-
-
Save Resisty/b884876c4940a9a134e04f37897b34d6 to your computer and use it in GitHub Desktop.
Exception-Driven FizzBuzz
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 fb(i, n): | |
try: | |
assert i <= n | |
three = i % 3 | |
five = i % 5 | |
p0d = 1/(three+five) | |
pve = int('0'*five) | |
pke = {1:'',2:''}[three] | |
print i | |
except ZeroDivisionError: | |
print '%d Fizzbuzz' % i | |
except ValueError: | |
print '%d Buzz' %i | |
except KeyError: | |
print '%d Fizz' % i | |
except AssertionError: | |
return | |
fb(i+1,n) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment