Last active
March 4, 2018 00:21
-
-
Save brdsio/53a3fe32fbf3e227cc487d6a3fd5626d to your computer and use it in GitHub Desktop.
Função para validar CPF
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 validate_cpf(cpf): | |
validate = lambda cpf: sum([a*b for a, b in zip(map(int, list(cpf)), range(1, 10, 1))]) % 11 | |
first_digit = validate(cpf) | |
second_digit = validate(cpf[1:-1]) | |
return int(cpf[-2]) == first_digit and int(cpf[-1]) == second_digit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment