python - What am I doing wrong here? IF and Else statement -
my goal here read through bunch of rows in records. if second column of record (row[1]) equal 133 in example prints out first , second column.
i running issue though:
line 11 - else: issue
import sqlite3 conn = sqlite3.connect('db.sqlite') print "opened database successfully"; cur = conn.execute("select * sightings") row = cur.fetchone() while row not none: if row[1] == 133: print row[0], row[1] else: row = cur.fetchone(): cur.close() conn.close()
you have colon @ end of statement not need
if row[1] == 133: print row[0], row[1] else: row = cur.fetchone(): <----
should be..
if row[1] == 133: print row[0], row[1] else: row = cur.fetchone()
Comments
Post a Comment