title: Python NLP: TypeError: not all arguments converted during string formatting
body: <p>I tried the code on "Natural language processing with python", but a type error occurred.</p>
  
  <pre><code>import nltk
  from nltk.corpus import brown
  
  suffix_fdist = nltk.FreqDist()
  for word in brown.words():
      word = word.lower()
      suffix_fdist.inc(word[-1:])
      suffix_fdist.inc(word[-2:])
      suffix_fdist.inc(word[-3:])
  common_suffixes = suffix_fdist.items()[:100]
  
  def pos_features(word):
      features = {}
      for suffix in common_suffixes:
          features['endswith(%s)' % suffix] = word.lower().endswith(suffix)
      return features
  pos_features('people')
  </code></pre>
  
  <p>the error is below:</p>
  
  <pre><code>Traceback (most recent call last):
    File "/home/wanglan/javadevelop/TestPython/src/FirstModule.py", line 323, in &lt;module&gt;
      pos_features('people')
    File "/home/wanglan/javadevelop/TestPython/src/FirstModule.py", line 321, in pos_features
      features['endswith(%s)' % suffix] = word.lower().endswith(suffix)
  TypeError: not all arguments converted during string formatting
  </code></pre>
  
  <p>Does anyone could help me find out where i am wrong?</p>