Skip to content

Instantly share code, notes, and snippets.

@dkapitan
Created April 18, 2016 12:05
Show Gist options
  • Save dkapitan/ac8d0429b74c6be82f81815cb6042b79 to your computer and use it in GitHub Desktop.
Save dkapitan/ac8d0429b74c6be82f81815cb6042b79 to your computer and use it in GitHub Desktop.
BSN 11-proef
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