joseleeph

Untitled

Mar 31st, 2021
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. import cs50
  2. from sys import exit, argv
  3.  
  4. if len(argv) != 2:
  5. print("invalid number of command line arguments")
  6. exit(1)
  7. studb = cs50.SQL("sqlite:///students.db")
  8. students = studb.execute("SELECT first, middle, last, birth, house FROM students WHERE house = ?", argv[1])
  9. #students = studb.execute("SELECT first, middle, last, birth, house FROM students WHERE house = ? ORDER BY first", argv[1]) ... order by first name
  10. #students = studb.execute("SELECT first, middle, last, birth, house FROM students WHERE house == Gryffindor")
  11. for wiz in students:
  12. #if wiz["middle"] == '': #== none?
  13. if len(wiz) == 3:
  14. print(wiz["first"], end = " ")
  15. print(wiz["last"], end = ", ")
  16. #print(wiz[birth], end = "")
  17. #print(wiz["birth"], end = "")
  18. print("born " + str(wiz["birth"]))
  19. else:
  20. print(wiz["first"], end = " ")
  21. print(wiz["middle"], end = " ")
  22. print(wiz["last"], end = ", ")
  23. print("born " + str(wiz["birth"]))
Advertisement
Add Comment
Please, Sign In to add comment