Created
December 13, 2012 10:53
-
-
Save georgespingos/4275696 to your computer and use it in GitHub Desktop.
Python AMKA Validator (no string slice)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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