Skip to content

Instantly share code, notes, and snippets.

@apalala
Forked from anonymous/Validar digito del RIF
Last active August 29, 2015 14:07
Show Gist options
  • Save apalala/2848b682931bb4cd319b to your computer and use it in GitHub Desktop.
Save apalala/2848b682931bb4cd319b to your computer and use it in GitHub Desktop.
def digito_rif(ci):
'''
toma un nro de cedula o rif y verifica el digito validador
'''
base = {'V': 1 * 4, 'E': 2 * 4, 'J': 3 * 4}
oper = [0, 3, 2, 7, 6, 5, 4, 3, 2]
for i in range(len(ci[:9])):
if i == 0:
val = base.get(ci[0], 0)
else:
val += oper[i] * int(ci[i])
digit = 11 - (val % 11)
print digit
return '%s%s' % (ci[:9], str(digit)[-1])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment