Skip to content

Instantly share code, notes, and snippets.

@brdsio
Last active March 4, 2018 00:21
Show Gist options
  • Save brdsio/53a3fe32fbf3e227cc487d6a3fd5626d to your computer and use it in GitHub Desktop.
Save brdsio/53a3fe32fbf3e227cc487d6a3fd5626d to your computer and use it in GitHub Desktop.
Função para validar CPF
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