Skip to content

Instantly share code, notes, and snippets.

@Resisty
Created July 13, 2020 03:12
Show Gist options
  • Save Resisty/b884876c4940a9a134e04f37897b34d6 to your computer and use it in GitHub Desktop.
Save Resisty/b884876c4940a9a134e04f37897b34d6 to your computer and use it in GitHub Desktop.
Exception-Driven FizzBuzz
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