Skip to content

Instantly share code, notes, and snippets.

@georgespingos
Created December 13, 2012 10:53
Show Gist options
  • Save georgespingos/4275696 to your computer and use it in GitHub Desktop.
Save georgespingos/4275696 to your computer and use it in GitHub Desktop.
Python AMKA Validator (no string slice)
def ValidateAMKA (amka):
if len(amka) != 11 or amka.isdigit() == False:
return False
else:
sum = int(amka[10])
i = 0
for s in amka[0:10]:
if i%2 != 0:
if int(s)* 2 > 9:
sum += int(s)*2 % 10+1
else:
sum += int(s)* 2
else:
sum += int(s)
i = i + 1
if sum%10 == 0:
return True
else:
return False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment