{"action":"created","comment":{"url":"https://api.github.com/repos/pbc-2016/D09/pulls/comments/75122421","id":75122421,"diff_hunk":"@@ -45,6 +45,41 @@\n # and builds and returns a word/count dict for it.\n # Then print_words() and print_top() can just call the utility function.\n \n+def print_words(filename):\n+    d = dict()\n+    with open(filename, 'r') as f:\n+        data = f.read()\n+        # why can't I just do words=f.split()? Why do I get AttributeError?\n+        # (Suppose we don't have to standardize the file to lower-cases)\n+        data_lower = data.lower()\n+        words = data_lower.split()\n+        for word in words:\n+        # When I initialize a dictionary within this for-loop,\n+        # even the same word is counted as separate keys\n+        # Why??\n+        # i.e. {'I': 1, 'standard': 1, 'create': 1, 'I':1, 'create': 1}","path":"HW09_wordcount.py","position":16,"original_position":16,"commit_id":"b476a73d5b5b4da895003890fc58d835d8bd221e","original_commit_id":"b476a73d5b5b4da895003890fc58d835d8bd221e","user":{"login":"danielsgriffin","id":6070690,"avatar_url":"https://avatars.githubusercontent.com/u/6070690?v=3","gravatar_id":"","url":"https://api.github.com/users/danielsgriffin","html_url":"https://github.com/danielsgriffin","followers_url":"https://api.github.com/users/danielsgriffin/followers","following_url":"https://api.github.com/users/danielsgriffin/following{/other_user}","gists_url":"https://api.github.com/users/danielsgriffin/gists{/gist_id}","starred_url":"https://api.github.com/users/danielsgriffin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danielsgriffin/subscriptions","organizations_url":"https://api.github.com/users/danielsgriffin/orgs","repos_url":"https://api.github.com/users/danielsgriffin/repos","events_url":"https://api.github.com/users/danielsgriffin/events{/privacy}","received_events_url":"https://api.github.com/users/danielsgriffin/received_events","type":"User","site_admin":false},"body":"(1) If you initialize w/in the for loop you will be recreating an empty dictionary each time you loop through. So what you would be doing is just adding the same key to a blank dictionary. \r\n(2) What you have typed out above is not possible in a dictionary, the keys must be unique.\r\nHere I will try to create such a dictionary and automatically it takes just the latter `'create'`\r\n```\r\n>>> d = {'I': 1, 'standard': 1, 'create': 1, 'I':1, 'create': 2}\r\n>>> d\r\n{'standard': 1, 'I': 1, 'create': 2}\r\n```","created_at":"2016-08-17T13:32:37Z","updated_at":"2016-08-17T13:32:37Z","html_url":"https://github.com/pbc-2016/D09/pull/20#discussion_r75122421","pull_request_url":"https://api.github.com/repos/pbc-2016/D09/pulls/20","_links":{"self":{"href":"https://api.github.com/repos/pbc-2016/D09/pulls/comments/75122421"},"html":{"href":"https://github.com/pbc-2016/D09/pull/20#discussion_r75122421"},"pull_request":{"href":"https://api.github.com/repos/pbc-2016/D09/pulls/20"}}},"pull_request":{"url":"https://api.github.com/repos/pbc-2016/D09/pulls/20","id":81521951,"html_url":"https://github.com/pbc-2016/D09/pull/20","diff_url":"https://github.com/pbc-2016/D09/pull/20.diff","patch_url":"https://github.com/pbc-2016/D09/pull/20.patch","issue_url":"https://api.github.com/repos/pbc-2016/D09/issues/20","number":20,"state":"open","locked":false,"title":"D09 hw","user":{"login":"gosophiego","id":20730838,"avatar_url":"https://avatars.githubusercontent.com/u/20730838?v=3","gravatar_id":"","url":"https://api.github.com/users/gosophiego","html_url":"https://github.com/gosophiego","followers_url":"https://api.github.com/users/gosophiego/followers","following_url":"https://api.github.com/users/gosophiego/following{/other_user}","gists_url":"https://api.github.com/users/gosophiego/gists{/gist_id}","starred_url":"https://api.github.com/users/gosophiego/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gosophiego/subscriptions","organizations_url":"https://api.github.com/users/gosophiego/orgs","repos_url":"https://api.github.com/users/gosophiego/repos","events_url":"https://api.github.com/users/gosophiego/events{/privacy}","received_events_url":"https://api.github.com/users/gosophiego/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-08-16T18:36:01Z","updated_at":"2016-08-17T13:32:37Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a138133fc86b635ae87f91c6581f9e758e4e1407","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/pbc-2016/D09/pulls/20/commits","review_comments_url":"https://api.github.com/repos/pbc-2016/D09/pulls/20/comments","review_comment_url":"https://api.github.com/repos/pbc-2016/D09/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pbc-2016/D09/issues/20/comments","statuses_url":"https://api.github.com/repos/pbc-2016/D09/statuses/b476a73d5b5b4da895003890fc58d835d8bd221e","head":{"label":"gosophiego:master","ref":"master","sha":"b476a73d5b5b4da895003890fc58d835d8bd221e","user":{"login":"gosophiego","id":20730838,"avatar_url":"https://avatars.githubusercontent.com/u/20730838?v=3","gravatar_id":"","url":"https://api.github.com/users/gosophiego","html_url":"https://github.com/gosophiego","followers_url":"https://api.github.com/users/gosophiego/followers","following_url":"https://api.github.com/users/gosophiego/following{/other_user}","gists_url":"https://api.github.com/users/gosophiego/gists{/gist_id}","starred_url":"https://api.github.com/users/gosophiego/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gosophiego/subscriptions","organizations_url":"https://api.github.com/users/gosophiego/orgs","repos_url":"https://api.github.com/users/gosophiego/repos","events_url":"https://api.github.com/users/gosophiego/events{/privacy}","received_events_url":"https://api.github.com/users/gosophiego/received_events","type":"User","site_admin":false},"repo":{"id":65796682,"name":"D09","full_name":"gosophiego/D09","owner":{"login":"gosophiego","id":20730838,"avatar_url":"https://avatars.githubusercontent.com/u/20730838?v=3","gravatar_id":"","url":"https://api.github.com/users/gosophiego","html_url":"https://github.com/gosophiego","followers_url":"https://api.github.com/users/gosophiego/followers","following_url":"https://api.github.com/users/gosophiego/following{/other_user}","gists_url":"https://api.github.com/users/gosophiego/gists{/gist_id}","starred_url":"https://api.github.com/users/gosophiego/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gosophiego/subscriptions","organizations_url":"https://api.github.com/users/gosophiego/orgs","repos_url":"https://api.github.com/users/gosophiego/repos","events_url":"https://api.github.com/users/gosophiego/events{/privacy}","received_events_url":"https://api.github.com/users/gosophiego/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/gosophiego/D09","description":null,"fork":true,"url":"https://api.github.com/repos/gosophiego/D09","forks_url":"https://api.github.com/repos/gosophiego/D09/forks","keys_url":"https://api.github.com/repos/gosophiego/D09/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gosophiego/D09/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gosophiego/D09/teams","hooks_url":"https://api.github.com/repos/gosophiego/D09/hooks","issue_events_url":"https://api.github.com/repos/gosophiego/D09/issues/events{/number}","events_url":"https://api.github.com/repos/gosophiego/D09/events","assignees_url":"https://api.github.com/repos/gosophiego/D09/assignees{/user}","branches_url":"https://api.github.com/repos/gosophiego/D09/branches{/branch}","tags_url":"https://api.github.com/repos/gosophiego/D09/tags","blobs_url":"https://api.github.com/repos/gosophiego/D09/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gosophiego/D09/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gosophiego/D09/git/refs{/sha}","trees_url":"https://api.github.com/repos/gosophiego/D09/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gosophiego/D09/statuses/{sha}","languages_url":"https://api.github.com/repos/gosophiego/D09/languages","stargazers_url":"https://api.github.com/repos/gosophiego/D09/stargazers","contributors_url":"https://api.github.com/repos/gosophiego/D09/contributors","subscribers_url":"https://api.github.com/repos/gosophiego/D09/subscribers","subscription_url":"https://api.github.com/repos/gosophiego/D09/subscription","commits_url":"https://api.github.com/repos/gosophiego/D09/commits{/sha}","git_commits_url":"https://api.github.com/repos/gosophiego/D09/git/commits{/sha}","comments_url":"https://api.github.com/repos/gosophiego/D09/comments{/number}","issue_comment_url":"https://api.github.com/repos/gosophiego/D09/issues/comments{/number}","contents_url":"https://api.github.com/repos/gosophiego/D09/contents/{+path}","compare_url":"https://api.github.com/repos/gosophiego/D09/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gosophiego/D09/merges","archive_url":"https://api.github.com/repos/gosophiego/D09/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gosophiego/D09/downloads","issues_url":"https://api.github.com/repos/gosophiego/D09/issues{/number}","pulls_url":"https://api.github.com/repos/gosophiego/D09/pulls{/number}","milestones_url":"https://api.github.com/repos/gosophiego/D09/milestones{/number}","notifications_url":"https://api.github.com/repos/gosophiego/D09/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gosophiego/D09/labels{/name}","releases_url":"https://api.github.com/repos/gosophiego/D09/releases{/id}","deployments_url":"https://api.github.com/repos/gosophiego/D09/deployments","created_at":"2016-08-16T07:16:00Z","updated_at":"2016-08-16T07:16:01Z","pushed_at":"2016-08-16T18:34:19Z","git_url":"git://github.com/gosophiego/D09.git","ssh_url":"git@github.com:gosophiego/D09.git","clone_url":"https://github.com/gosophiego/D09.git","svn_url":"https://github.com/gosophiego/D09","homepage":null,"size":338,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"pbc-2016:master","ref":"master","sha":"6ddf22343408d2da9dce5a646088bfdcd024ecdc","user":{"login":"pbc-2016","id":20786246,"avatar_url":"https://avatars.githubusercontent.com/u/20786246?v=3","gravatar_id":"","url":"https://api.github.com/users/pbc-2016","html_url":"https://github.com/pbc-2016","followers_url":"https://api.github.com/users/pbc-2016/followers","following_url":"https://api.github.com/users/pbc-2016/following{/other_user}","gists_url":"https://api.github.com/users/pbc-2016/gists{/gist_id}","starred_url":"https://api.github.com/users/pbc-2016/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pbc-2016/subscriptions","organizations_url":"https://api.github.com/users/pbc-2016/orgs","repos_url":"https://api.github.com/users/pbc-2016/repos","events_url":"https://api.github.com/users/pbc-2016/events{/privacy}","received_events_url":"https://api.github.com/users/pbc-2016/received_events","type":"Organization","site_admin":false},"repo":{"id":65735634,"name":"D09","full_name":"pbc-2016/D09","owner":{"login":"pbc-2016","id":20786246,"avatar_url":"https://avatars.githubusercontent.com/u/20786246?v=3","gravatar_id":"","url":"https://api.github.com/users/pbc-2016","html_url":"https://github.com/pbc-2016","followers_url":"https://api.github.com/users/pbc-2016/followers","following_url":"https://api.github.com/users/pbc-2016/following{/other_user}","gists_url":"https://api.github.com/users/pbc-2016/gists{/gist_id}","starred_url":"https://api.github.com/users/pbc-2016/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pbc-2016/subscriptions","organizations_url":"https://api.github.com/users/pbc-2016/orgs","repos_url":"https://api.github.com/users/pbc-2016/repos","events_url":"https://api.github.com/users/pbc-2016/events{/privacy}","received_events_url":"https://api.github.com/users/pbc-2016/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/pbc-2016/D09","description":null,"fork":false,"url":"https://api.github.com/repos/pbc-2016/D09","forks_url":"https://api.github.com/repos/pbc-2016/D09/forks","keys_url":"https://api.github.com/repos/pbc-2016/D09/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pbc-2016/D09/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pbc-2016/D09/teams","hooks_url":"https://api.github.com/repos/pbc-2016/D09/hooks","issue_events_url":"https://api.github.com/repos/pbc-2016/D09/issues/events{/number}","events_url":"https://api.github.com/repos/pbc-2016/D09/events","assignees_url":"https://api.github.com/repos/pbc-2016/D09/assignees{/user}","branches_url":"https://api.github.com/repos/pbc-2016/D09/branches{/branch}","tags_url":"https://api.github.com/repos/pbc-2016/D09/tags","blobs_url":"https://api.github.com/repos/pbc-2016/D09/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pbc-2016/D09/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pbc-2016/D09/git/refs{/sha}","trees_url":"https://api.github.com/repos/pbc-2016/D09/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pbc-2016/D09/statuses/{sha}","languages_url":"https://api.github.com/repos/pbc-2016/D09/languages","stargazers_url":"https://api.github.com/repos/pbc-2016/D09/stargazers","contributors_url":"https://api.github.com/repos/pbc-2016/D09/contributors","subscribers_url":"https://api.github.com/repos/pbc-2016/D09/subscribers","subscription_url":"https://api.github.com/repos/pbc-2016/D09/subscription","commits_url":"https://api.github.com/repos/pbc-2016/D09/commits{/sha}","git_commits_url":"https://api.github.com/repos/pbc-2016/D09/git/commits{/sha}","comments_url":"https://api.github.com/repos/pbc-2016/D09/comments{/number}","issue_comment_url":"https://api.github.com/repos/pbc-2016/D09/issues/comments{/number}","contents_url":"https://api.github.com/repos/pbc-2016/D09/contents/{+path}","compare_url":"https://api.github.com/repos/pbc-2016/D09/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pbc-2016/D09/merges","archive_url":"https://api.github.com/repos/pbc-2016/D09/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pbc-2016/D09/downloads","issues_url":"https://api.github.com/repos/pbc-2016/D09/issues{/number}","pulls_url":"https://api.github.com/repos/pbc-2016/D09/pulls{/number}","milestones_url":"https://api.github.com/repos/pbc-2016/D09/milestones{/number}","notifications_url":"https://api.github.com/repos/pbc-2016/D09/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pbc-2016/D09/labels{/name}","releases_url":"https://api.github.com/repos/pbc-2016/D09/releases{/id}","deployments_url":"https://api.github.com/repos/pbc-2016/D09/deployments","created_at":"2016-08-15T13:49:23Z","updated_at":"2016-08-15T14:34:27Z","pushed_at":"2016-08-16T18:36:01Z","git_url":"git://github.com/pbc-2016/D09.git","ssh_url":"git@github.com:pbc-2016/D09.git","clone_url":"https://github.com/pbc-2016/D09.git","svn_url":"https://github.com/pbc-2016/D09","homepage":null,"size":337,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":32,"mirror_url":null,"open_issues_count":20,"forks":32,"open_issues":20,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/pbc-2016/D09/pulls/20"},"html":{"href":"https://github.com/pbc-2016/D09/pull/20"},"issue":{"href":"https://api.github.com/repos/pbc-2016/D09/issues/20"},"comments":{"href":"https://api.github.com/repos/pbc-2016/D09/issues/20/comments"},"review_comments":{"href":"https://api.github.com/repos/pbc-2016/D09/pulls/20/comments"},"review_comment":{"href":"https://api.github.com/repos/pbc-2016/D09/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pbc-2016/D09/pulls/20/commits"},"statuses":{"href":"https://api.github.com/repos/pbc-2016/D09/statuses/b476a73d5b5b4da895003890fc58d835d8bd221e"}}}}
{"actor":{"display_login":"danielsgriffin"}}