title: Summation with values in a dictionary (Python)
body: <p>I am struggling with using summation in Python. </p>
  I obtain input, which is then autocorrected and all punctuation is removed:</p>
  <pre><code>text=input(&quot;Enter your text here: )
  </code></pre>
  <p>Then, I have a dictionary:</p>
  <pre><code>bread = {&quot;bread&quot;: 7, &quot;sourdough crusts&quot;: 10}
  </code></pre>
  <p>I determined if any key from <code>bread</code> existed in <code>text</code> with the code:</p>
  <pre><code>result = re.findall('|'.join(bread), text)
  </code></pre>
  <p>I want to find the sum of all the values, should the corresponding key exist in <code>text</code>. At the moment, my code looks like this:</p>
  <pre><code>for sentence, rating in bread.items():
       ssum = 0
       for i in range(len(result)):
             ssum = ssum + rating
  print(&quot;Sum: &quot; + str(ssum))
  </code></pre>
  <p>However, this produces incredibly random results. For example, if</p>
  <pre><code>text = bread sourdough crusts
  </code></pre>
  <p>It says that</p>
  <pre><code>ssum = 20
  </code></pre>
  <p>(even though it should equal 17). </p> What is going on here, and how do I fix it?</p>