query = "SELECT car FROM cars....."
cursor.execute(query)
results = cursor.fetchall()
for row in results:
if not query:
print 'No cars available."
else:
print row[0]
What I'm trying to do is print a message if results are null, or print the results if they have entries. The above code is what I have so far but obviously isn't working. Any suggestions?
Thanks in advance.
queryis a string defined at the top, soif not query:will never succeed. Try testingrowinstead?'No cars available."with a single quote, but close with a double quote