Skip to content

Instantly share code, notes, and snippets.

@ik5
Created September 7, 2020 18:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ik5/56f0151da7f293750eba390fe2963f39 to your computer and use it in GitHub Desktop.
Save ik5/56f0151da7f293750eba390fe2963f39 to your computer and use it in GitHub Desktop.
calc israeli id number for valid last number in python 2
#!/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