python for loop tuple index out of range
<p>I'm still trying to get the hang of python, so bear with me. please. I have this bit of code that I'm using from a book. The book does not properly show the white space in the code, so the spacing is my best guess. This code is supposed to break the results of a MySQL query into a more readable format. </p>

<pre><code>if form is True:
columns_query = """DESCRIBE %s""" % (table)
print columns_query
columns_command = cursor.execute(columns_query)
headers = cursor.fetchall()
column_list = []
for record in headers:
    column_list.append(record[0])
output=""
for record in results:
    output = output + "===================================\n\n"
for field_no in xrange(0, len(column_list)):
    output = output + column_list[field_no] + ": " + str(record[field_no]) + "\n"
output = output + "\n"
</code></pre>

<p>When I try to run it, I get the following:</p>

<pre><code>Traceback (most recent call last):
  File "odata_search.py", line 46, in &lt;module&gt;
    output = output + column_list[field_no] + ": " + str(record[field_no]) + "\n"
IndexError: tuple index out of range
</code></pre>

<p>It has something to do with the <code>str(record[field_no])</code> portion of the code, but that's what it looks like in the book, so I'm not sure what else to try.</p>
