Python- File Parsing
<blockquote>
  <p>Write a program which reads a text
  file called input.txt which contains
  an arbitrary number of lines of the
  form ", " then records this
  information using a dictionary, and
  finally outputs to the screen a list
  of countries represented in the file
  and the number of cities contained.</p>
</blockquote>

<p>For example, if input.txt contained the following:</p>

<pre><code>New York, US
Angers, France
Los Angeles, US
Pau, France
Dunkerque, France
Mecca, Saudi Arabia
</code></pre>

<p>The program would output the following (in some order):</p>

<pre><code>Saudi Arabia : 1
US : 2
France : 3
</code></pre>

<p>My code:</p>

<pre><code>from os import dirname

def parseFile(filename, envin, envout = {}):
    exec "from sys import path" in envin
    exec "path.append(\"" + dirname(filename) + "\")" in envin
    envin.pop("path")
    lines = open(filename, 'r').read()
    exec lines in envin
    returndict = {}
    for key in envout:
        returndict[key] = envin[key]
    return returndict
</code></pre>

<p>I get a Syntax error: invalid syntax...  when I use my file name
i used file name input.txt  </p>
