Try Except in Python
<p>I want to take a path for a file, open the file and read the data within it. Upon doing so, I would like to count the number of occurrences of each letter in the alphabet.</p>

<p>Of what I have read and heard, using try/except would be best here. I've tried my best in this, but I only managed to count the occurrences of what letters were in a string within the program, and not within the file.</p>

<p>I haven't a clue how to do this now, and my brain is starting to hurt....this is what I have so far:</p>

<pre><code>import sys
print "Enter the file path:"
thefile = raw_input()
f = open(thefile, "r")
chars = {}
for c in f:
    try:
        chars[c]+=1
    except:
        chars[c]=1
print chars
</code></pre>

<p>Any help will be highly appreciated. Thank you.</p>

<p>EDIT: I forgot to say that the result I get at the minute says that the whole file is one character. The file consists of "abcdefghijklmnopqrstuvwxyz" and the resulting output is: {'"abcdefghijklmnopqrstuvwxyz"\n': 1} which it shouldn't be.</p>
