title: Python: < not supported between str and int
body: <p>I'm learning Python through <em>Automate the Boring Stuff</em> and I'm running into a something I don't quite understand.</p>
  
  <p>I'm trying to create a simple for loop that prints the elements of a list in this format: <code>W, X, Y, and Z</code>.</p>
  
  <p>My code looks like the following: </p>
  
  <pre><code>spam = ['apples', 'bananas', 'tofu', 'cats']
  
  def printSpam(item):
      for i in item:
          if i &lt; len(item)-1:
              print (','.join(str(item[i])))
          else:
              print ("and ".join(str(item[len(item)-1])))
      return
  
  printSpam(spam)
  </code></pre>
  
  <p>I get this error in response: </p>
  
  <pre><code>Traceback (most recent call last):
    File "CH4_ListFunction.py", line 11, in &lt;module&gt;
      printSpam(spam)
    File "CH4_ListFunction.py", line 5, in printSpam
      if i &lt; len(item)-1:
  TypeError: '&lt;' not supported between instances of 'str' and 'int'
  </code></pre>
  
  <p>Any help is appreciated.  Thanks for helping a newbie.</p>