Skip to content

Commit 3ef7bcc

Browse files
refactor iban_checksum function to improve numeric conversion and return value
1 parent 27e0b11 commit 3ef7bcc

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

src/fdlearn/resources/patterns.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,12 @@ def iban_checksum(iban: str) -> str:
148148
country = iban[:2]
149149
bban = iban[4:]
150150
moved = bban + country + "00"
151-
numeric = "".join(str(int(ch, 36)) for ch in moved)
151+
numeric = ''.join(str(ord(ch) - 55) if ch.isalpha() else ch for ch in moved)
152152
remainder = int(numeric) % 97
153-
return 98 - remainder
154-
155-
where iban_checksum(str(<NON_TERMINAL>)) == int(<NON_TERMINAL>)
153+
check_digits = 98 - remainder
154+
return check_digits
155+
156+
where int(iban_checksum(str(<NON_TERMINAL>))) == int(<NON_TERMINAL>)
156157
"""
157158
)
158159

0 commit comments

Comments
 (0)