title: How to fix "TypeError: 'str' object is not callable" error in Python?
body: <p>I'm trying to rank words used in one document by their frequency in another document. </p>
  
  <p>As I am a beginner, I asked someone to help me with the code, and this is what they sent me. It's giving me an error.</p>
  
  <pre class="lang-py prettyprint-override"><code>from collections import defaultdict
  occurences = defaultdict(int)
  with open("booksandtranscripts.txt","r") as file:
      booksandtranscripts = file.read()
      for word in booksandtranscripts.split(" "):
          occurences[word] += 1
  words_and_frequencies = []
  with open("allminow.txt","r") as file:
      allminow = file.read()
      for word in allminow.split(" "):
          words_and_frequencies.append((occurences[word],[word]))
  for frequency,word in sorted(words_and_frequencies):
      print("%s : %i %" (word, frequency))
  </code></pre>
  
  <p>I expected it to print the words of one document alongside them the frequencies of those words in the other document. I know this code doesn't export csv, but I was planning on attempting to add that too. </p>
  
  <p>Here is the error I got: </p>
  
  <pre class="lang-py prettyprint-override"><code>Traceback (most recent call last):
    line 15, in &lt;module&gt;
      print("%s : %i %" (word, frequency))
  TypeError: 'str' object is not callable
  </code></pre>