Reputation: 51
OK, so I am pulling some data from a sqlite database and I can't figure out how to properly format them when showing to the users...I'm using python 2.5.
studentid = raw_input("Enter your student ID: ")
cur.execute('SELECT APP_DECISION FROM APP_STATUS WHERE STUDENTID = ?', (studentid,))
appdecision = cur.fetchall()
cur.execute('SELECT GRANT FROM FINAID WHERE STUDENTID = ?', (studentid,))
grant = cur.fetchall()
if (appdecision == 'ACCEPTED'):
print 'congratulations'
else:
print 'sorry'
print (appdecision)
print (grant)
the results are getting printed like so,
Enter your student ID: 100006
[(u'ACCEPTED',)]
[(9500,)]
I want to be able to print it such as Accepted, and $9500....also. How do I check for the specific value so I can congratulate the users which have been accepted? Thanks so much!
Upvotes: 0
Views: 176
Reputation: 78610
Print it as:
print (appdecision[0][0])
print (grant[0][0])
This is because [(u'ACCEPTED',)]
is a list that contains a tuple that contains the string "ACCEPTED"
. Similarly, you'll have to check for a value like this:
if appdecision[0][0] == "ACCEPTED":
print "Congratulations!"
Upvotes: 1