Skip to content

Instantly share code, notes, and snippets.

@Dreamersoul
Last active November 23, 2016 11:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Dreamersoul/a9c42188927190a053559eec5621a0a2 to your computer and use it in GitHub Desktop.
Save Dreamersoul/a9c42188927190a053559eec5621a0a2 to your computer and use it in GitHub Desktop.
civil id validation
civil_id = "CIVIL ID HERE" # ex "2950980214009"
civil_id = map(int, civil_id)
multiples = [2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2]
summation = sum([a*b for a,b in zip(civil_id[:-1],multiples)]) # Multiply each number with its weight then sum them together
check = ((11-summation%11) == civil_id[11])
print check
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment