Trying to finish roster.py and my output is incorrect. It prints the None instead of the last name and I am getting and extra space after the last printed name, such as "None , born 1981" or "Jean , born 1979". Any help would be much appreciated because this is my first time coding and my google searches have been fruitless.
import cs50
import sys
import sqlite3
db = sqlite3.connect("students.db")
cursor = db.cursor()
if (len(sys.argv) != 2):
print("Usage: python roster.py -house")
house_name = sys.argv[1],
cursor.execute("SELECT first, middle, last, birth FROM students WHERE house = ? ORDER BY last", house_name)
row = cursor.fetchone()
for row in cursor:
print(row[0], row[1] if (row[1] != 'None') else row[2],', born', row[3])