Created
October 27, 2020 15:22
-
-
Save walison17/113e7b51f2e6d64c1fcc7a4356bb7753 to your computer and use it in GitHub Desktop.
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 converter_para_inteiro(valor): | |
""" | |
>>> converter_para_inteiro('-') | |
>>> converter_para_inteiro('') | |
>>> converter_para_inteiro('N/I') | |
>>> converter_para_inteiro('nao esperado') | |
>>> converter_para_inteiro('10') | |
10 | |
""" | |
if str(valor).upper() in ['-', '', 'N/I']: | |
return None | |
try: | |
return int(valor) | |
except ValueError: | |
return None |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment