Nested for loop using dict
<p>I am doing a Coursera python exercise and having trouble writing my code.</p>
<p>The question is as following:</p>
<blockquote>
<p>Write a program to read through the <code>mbox-short.txt</code> and figure out who has the sent the greatest number of mail messages. The program looks for 'From ' lines and takes the second word of those lines as the person who sent the mail.</p>
<p>The program creates a Python dictionary that maps the sender's mail address to a count of the number of times they appear in the file. After the dictionary is produced, the program reads through the dictionary using a maximum loop to find the most prolific committer.</p>
</blockquote>
<p>The sample text file is in this line:
<a href="http://www.pythonlearn.com/code/mbox-short.txt" rel="nofollow noreferrer">http://www.pythonlearn.com/code/mbox-short.txt</a></p>
<p>And the expected output should be:</p>
<pre><code>cwen@iupui.edu 5
</code></pre>
<p>This is my code:</p>
<pre><code>name = raw_input(&quot;Enter file:&quot;)
if len(name) &lt; 1 : name = &quot;mbox-short.txt&quot;
handle = open(name)
count = dict()

for line in handle:
    word = line.split()
    if line.startswith('From '):
        email = word[1]
        for sender in email:
            if sender not in count:
                count[sender] = count.get(sender, 0) + 1

bigcount = None
bigname = None
for name,count in count.items():
    if bigname is None or count &gt; bigcount:
        bigname = name
        bigcount = count
print bigname, bigcount
</code></pre>
<p>The output I have is:</p>
<pre><code>. 1
</code></pre>
<p>I think there is something wrong in &quot;for sender in email&quot; part, but couldn't figure out how it results in the undesired output.</p>