Last active
May 19, 2021 04:10
-
-
Save ychoi-kr/cf61a7da0ae064439f5fa9bbb00773ce to your computer and use it in GitHub Desktop.
simple type inference with try-except in python
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 triple_input_number(): | |
... x = input() | |
... try: | |
... n = int(x) | |
... return n * 3 | |
... except: | |
... pass | |
... | |
>>> triple_input_number() | |
3 | |
9 | |
>>> triple_input_number() | |
a |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment