Created
April 18, 2016 12:05
-
-
Save dkapitan/ac8d0429b74c6be82f81815cb6042b79 to your computer and use it in GitHub Desktop.
BSN 11-proef
This file contains 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 bsnproef(nummer): | |
""" | |
Checks validity of Dutch Social Security (BSN) based on '11-proef' | |
:param nummer: number to be checked, can be string or int | |
:return: True if passed BSN proef, False otherwise | |
""" | |
bsnfactoren = [9, 8, 7, 6, 5, 4, 3, 2, -1] | |
try: | |
check = sum([int(a)*b for a, b in zip(str(nummer), bsnfactoren)]) % 11 | |
if check == 0: | |
return True | |
else: | |
return False | |
except: | |
return False |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment