Skip to content

Instantly share code, notes, and snippets.

@twpayne
Forked from fredj/awb.py
Created October 25, 2012 14:24
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 twpayne/3952828 to your computer and use it in GitHub Desktop.
Save twpayne/3952828 to your computer and use it in GitHub Desktop.
AWB (Airway bill) number validation
import re
def valid(awb):
m = re.match('\d{3}(?P<serial>\d{7})(?P<check>\d)\Z', awb)
return m and int(m.group('serial')) % 7 == int(m.group('check'))
@fredj
Copy link

fredj commented Oct 25, 2012

valid(42) throws a TypeError: expected string or buffer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment