My code run right and My output same they output but after submitted get 17% why
//import.py
from sys import argv, exit
import cs50
import csv
if len(argv) != 2:
print("missing command-line argument")
exit(1)
open(f"students.db","w").close()
db = cs50.SQL("sqlite:///students.db")
db.execute("CREATE TABLE student (id INTEGER PRIMARY KEY AUTOINCREMENT, first TEXT, middle TEXT, last TEXT, house TEXT, birth NUMERIC)")
with open(argv[1],"r") as titles:
reader = csv.DictReader(titles)
for row in reader:
name = row["name"]
house = row["house"]
birth = int(row["birth"])
part = name.split();
if(len(part) == 3):
db.execute("INSERT INTO student(first,middle,last,house,birth) VALUES (?,?,?,?,?)",
part[0],part[1],part[2],house,birth)
elif (len(part) == 2):
db.execute("INSERT INTO student(first,last,house,birth) VALUES (?,?,?,?)",
part[0],part[1],house,birth)
//roster.py
from sys import argv, exit
import cs50
if len(argv) != 2:
print("missing command-line argument")
exit(1)
db = cs50.SQL("sqlite:///students.db")
house = argv[1]
rows = db.execute("SELECT first,middle,last,birth FROM student WHERE house = ? ORDER BY last,first",argv[1])
for row in rows:
if(row["middle"]== None):
print(row["first"]+" "+row["last"]+", born "+str(row["birth"]))
else:
print(row["first"]+" "+row["middle"]+" "+row["last"]+", born "+str(row["birth"]))