title: Python - U.S. ZipCode Matching
body: <p>I'm working with Regex and I'm brand new to using python. I can't get the program to read from file and go through the match case properly. I'm getting a traceback error that looks like this:</p>
  
  <pre><code>Traceback (most recent call last):
      File "C:\Users\Systematic\workspace\Project8\src\zipcode.py", line 18, in &lt;module&gt;
        m = re.match(info, pattern)
      File "C:\Python34\lib\re.py", line 160, in match
        return _compile(pattern, flags).match(string)
      File "C:\Python34\lib\re.py", line 282, in _compile
        p, loc = _cache[type(pattern), pattern, flags]
  TypeError: unhashable type: 'list'
  </code></pre>
  
  <p>zipin.txt:</p>
  
  <pre><code>3285
  32816
  32816-2362
  32765-a234
  32765-23
  99999-9999
  </code></pre>
  
  <p>zipcode.py:</p>
  
  <pre><code>from pip._vendor.distlib.compat import raw_input
  import re
  
  userinput = raw_input('Please enter the name of the file containing the input zipcodes: ')
  
  myfile = open(userinput)
  
  info = myfile.readlines()
  
  pattern = '^[0-9]{5}(?:-[0-9]{4})?$'
  
  m = re.match(info, pattern)
  
  if m is not None:
      print("Match found - valid U.S. zipcode: " , info, "\n")
  else: print("Error - no match - invalid U.S. zipcode: ", info, "\n")
  
  myfile.close()
  </code></pre>