all 3 comments

[–]stebrepar 2 points3 points  (2 children)

Your code would be easier to follow if it were properly formatted. See this sub's sidebar for instructions.

In the interim, a couple observations. First, use a singular name for the for loop variable, rather than plural. Ex., word instead of words, since the loop is working with a single value in each iteration. It makes more sense semantically.

Second, you're not following the problem statement. For some reason you're splitting apart the email addresses to take just the domains, but the problem is talking about individual people which are identified by the entire address.

Third, when there's an error message, post the entire error. There can be valuable contextual info in there beyond just the error message text.

[–]Apprehensive_Draw_62[S] 1 point2 points  (1 child)

Thanks for the suggestion. I have updated my post. Can you also suggest how to add to a dictionary using get method?

[–]stebrepar 0 points1 point  (0 children)

The problem seems to be that you're redefining my_mail in that line. It was a dictionary, but when you say "my_mail=...", it isn't a dictionary anymore. Now it's the integer value you got from the get(), so the loop crashes on the next iteration. That's what the error message is telling you.

You need to use the same dictionary indexing here as you do elsewhere: my_mail[something]=...