title: Sum key-values pairs in a text file
body: <p>My for-loop is not working properly.<br />
  I want to group the same keys and sum their values.
  For example, sum all of the <code>yes</code> values and display it in one row.
  The information in game.txt is looking like this:</p>
  <pre><code>yes 5
  maybe 9
  yes 2
  maybe 10
  maybe 7
  no 25
  yes 1
  </code></pre>
  <p>the print looks like this;</p>
  <pre><code>{'no': '25', 'yes': '1', 'maybe': '10'}
  </code></pre>
  <p>And my code looks like this;</p>
  <pre><code>test_scores = {}
  
  filename = input(&quot;Enter the name of the score file: &quot;)
  file = open(filename, mode=&quot;r&quot;)
  
  print(&quot;Contestant score: &quot;)
  
  for file_line in sorted(file):
      key, value = file_line.split()
      if key not in test_scores:
          test_scores.update({key: value})
  
  print(test_scores)
  </code></pre>
  <p>So what seems to be the problem and how to fix it?</p>