luhn_ok#
- scikitplot.cleanprompt.luhn_ok(digits)[source]#
Return whether
digitssatisfies the Luhn checksum.- Parameters:
- digitsstr
A string of decimal digits, already stripped of separators.
- Returns:
- bool
Truewhen the Luhn check passes and the length is plausible for a payment card (12 to 19 digits).
- Parameters:
digits (str)
- Return type:
Notes
Developer notes. Luhn is a transcription-error check, not a validity proof: it rejects roughly 90 percent of random digit runs, which is enough to keep order numbers and long identifiers out of the card category while never rejecting a genuine card.
Examples
>>> luhn_ok("4242424242424242") True >>> luhn_ok("4242424242424241") False