Categories
Development

How do you update a column with the enumerate function?

I’m trying to update a column with a grade (a*,a,b,c…) depending on where a student’s mark land within the grade boundaries.
The user has already specified what marks you need to get the required grade.

I’ve tried using the enumerate function, going through each record along with a list of the student’s mark (called listy)

while True:
  try:
     a_star = int(input("Raw mark to get A*: "))
  except ValueError:
    print("Has to be a valid number")
    continue
  else :
    break

while True:
  try:
    a = int(input("Raw mark to get A: "))
  except ValueError:
    print("Has to be a valid number")
    continue
  else :
    break

while True:
  try:
    b = int(input("Raw mark to get B: "))
  except ValueError:
    print("Has to be a valid number")
    continue
  else :
    break

while True:
  try:
    c = int(input("Raw mark to get C: "))
  except ValueError:
    print("Has to be a valid number")
    continue
  else :
    break

while True:
  try:
    d = int(input("Raw mark to get D: "))
  except ValueError:
    print("Has to be a valid number")
    continue
  else :
    break

while True:
  try:
    e = int(input("Raw mark to get E: "))
  except ValueError:
    print("Has to be a valid number")
    continue
  else :
    break

listy = []

for i in raw_mark:
  raw_mark_ = i[3]
  listy.append(raw_mark_)

# print("This is listy: ", listy)

for i, val in enumerate(listy):
  if val >= a_star:
    grade = "A*"
    c.execute("UPDATE class SET grade = (?) WHERE ID = (?)", (grade, (i + 1), ))
    # conn.commit()

  elif val >= a and i < a_star:
    grade = "A"
    c.execute("UPDATE class SET grade = (?) WHERE ID = (?)", (grade, (i + 1), ))
    # conn.commit()

  elif val >= b and i < a:
    grade = "B"
    c.execute("UPDATE class SET grade = (?) WHERE ID = (?)", (grade, (i + 1), ))
    # conn.commit()

  elif val >= c and i < b:
    grade = "C"
    c.execute("UPDATE class SET grade = (?) WHERE ID = (?)", (grade, (i + 1), ))
    # conn.commit()

  elif val >= d and i < c:
    grade = "D"
    c.execute("UPDATE class SET grade = (?) WHERE ID = (?)", (grade, (i + 1), ))
    # conn.commit()

  else :
    grade = "E"
    c.execute("UPDATE class SET grade = (?) WHERE ID = (?)", (grade, (i + 1), ))
    # conn.commit()

conn.commit()

this is the error i get:

elif val >=c and i=’ not supported between instances of ‘int’ and ‘sqlite3.Cursor’

Leave a Reply

Your email address will not be published. Required fields are marked *