Created
September 7, 2020 18:26
-
-
Save ik5/56f0151da7f293750eba390fe2963f39 to your computer and use it in GitHub Desktop.
calc israeli id number for valid last number in python 2
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
#!/usr/bin/env python2 | |
def validate_id_number(id_num): | |
anID = id_num.zfill(9) | |
return sum( | |
sum( | |
map( | |
int, str(int(a)*(i % 2 + 1)) | |
) | |
) for i, a in enumerate(anID)) % 10 == 0 | |
if __name__ == '__main__': | |
print(validate_id_number('123456782')) | |
# |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment