Skip to content

Instantly share code, notes, and snippets.

@sh4dowb
Last active December 25, 2020 18:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sh4dowb/3a2d31408c65482256b4e711050aea5b to your computer and use it in GitHub Desktop.
Save sh4dowb/3a2d31408c65482256b4e711050aea5b to your computer and use it in GitHub Desktop.
Netherlands IBAN account number checksum validator
# Netherlands account number algorithm uses this factor table:
# digit | factor
# 1st | 10
# 2nd | 9
# ...
# 10th | 1
#
# After multiplying digits according to the table, sum of these results must be divisible with 11
def validate(acc):
f = 10
total = 0
for a in acc:
total += int(a) * f
f -= 1
return total % 11 == 0
validate("1834239443") # True
validate("1234567890") # False
# Use schwifty module for IBAN validation, however,
# it does not support Netherlands account number validation,
# so validate it seperately with this function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment