Why am I getting replacement index 1 out of range for positional args tuple error

  python

I keep getting this error: Replacement index 1 out of range for positional args tuple
on this line of code:

print("'{1}', '{2}', '{3}', '{4}'".format(question[3]), question[4], question[5], question[6])

here is my full code


def quiz(userID,topicID):
    with sqlite3.connect("Quiz.db") as db:
        cursor = db.cursor()
    score = 0
    cursor.execute("SELECT * FROM questions WHERE topicID=?",[(topicID)])
    questions = cursor.fetchall()
    numOfQuestions = 0 #use to help work out the score / %
    for question in questions:
        topic = question[1]
        print(question[2])
        print("'{1}', '{2}', '{3}', '{4}'".format(question[3]), question[4], question[5], question[6])
        choice = input("Answer: ")
        if choice == question[7]:
            print("Correct")
            score += 1
            time.sleep(1)
            print("")
        else:
            print("Incorrect")
            numOfQuestions += 1
    #works our % to keep all quiz scores consistent
    score = int((score/numOfQuestions)*100)
    print("Your score was: ",score)
    insertData("INSERT INTO scores(userID,score,topicID) VALUES(?,?,?);")
    cursor.execute(insertData, [(userID), (score), (topic)])
    db.commit()

Source: Python Questions

LEAVE A COMMENT