Skip to content

Instantly share code, notes, and snippets.

@yngwie74
Created October 25, 2017 17:01
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 yngwie74/3e9a36c6ece067f003ba9cdb7ff920d3 to your computer and use it in GitHub Desktop.
Save yngwie74/3e9a36c6ece067f003ba9cdb7ff920d3 to your computer and use it in GitHub Desktop.
Cálculo del dígito verificador de la CLABE
#!/usr/bin/env python
from itertools import cycle, izip
def digver(clabe):
mult = cycle((3,7,1))
cta = (int(c) for c in clabe)
res = ((a * b) % 10 for (a, b) in izip(mult, cta))
return 10 - (sum(res) % 10)
banco = '014'
plaza = '180'
cuenta = 'xxxxxxx5528'
print banco, plaza, cuenta, digver(banco + plaza + cuenta)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment