Skip to content

Instantly share code, notes, and snippets.

@sepulchered
Last active November 7, 2017 20:54
Show Gist options
  • Save sepulchered/89744afc3e67084b9074575c567504ce to your computer and use it in GitHub Desktop.
Save sepulchered/89744afc3e67084b9074575c567504ce to your computer and use it in GitHub Desktop.
import typing
def divide(num: float, den: float) -> typing.Optional[float]:
try:
return num / den
except ZeroDivisionError:
return None
print(divide(1, 2))
print(divide(1, 0))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment