fork download
  1. # your code goes here
  2.  
  3. import re
  4.  
  5. postalCode = " 123 4th Street, Toronto, Ontario, M1A 1A1 "
  6.  
  7. #read First Line
  8. line = postalCode
  9.  
  10. if re.search("[ABCEGHJKLMNPRSTVXY][0-9][ABCEGHJKLMNPRSTVWXYZ] ?[0-9][ABCEGHJKLMNPRSTVWXYZ][0-9]", line):
  11. print 'Match found - valid Canadian address: ', line
  12. else:
  13. print 'Error - no match - invalid Canadian address:', line
  14.  
Success #stdin #stdout 0.02s 7108KB
stdin
Standard input is empty
stdout
Match found - valid Canadian address:   123 4th Street, Toronto, Ontario, M1A 1A1