Skip to content

Instantly share code, notes, and snippets.

Created October 7, 2014 21:36
Show Gist options
  • Save anonymous/553ac5910f4269962ea3 to your computer and use it in GitHub Desktop.
Save anonymous/553ac5910f4269962ea3 to your computer and use it in GitHub Desktop.
Validar digito del RIF (Venezuela)
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