Tuple looping (I think)
Question: I have this code for a quiz but only the first question appears. I can answer
the first question and the score will adjust accordingly however the next
question never appears. I have tried researching looping through tuples and
have played around with my code but to no avail. I am a Python newbie and
would appreciate some help please. I have spent hours on it believe me.

    
    
    from tkinter import *
    
    root = Tk()
    root.title("End of year exam")
    
    score = 0
    
    def submit_button_clicked():
        global score
        global questions
    
        score = 0
        if answer.get() == questions[0][1]:
            score+=1
        else:
            score = score
        scoretxt.config(text = "Your score is: {}".format(str(score)))
    
    
    questions =[("What does 13 + 5 = ?","18"),("What does 12 + 8 = ?","20"),("What does 19 + 6 = ?","25"),("What does 17 + 15 = ?","32")]
    
    Label(root,text = "Question : ",bg ="light grey").grid(row = 0,column = 0, sticky = W)
    question=Label(root,bg = "light green",text= questions[1][0], width = 38)
    question.grid(row =1,column=0)
    
    Label(root,text = "Answer: ",bg = "light grey").grid(row = 2, column = 0, sticky = W)
    answer = Entry(root,bg ="white",width = 45, justify = CENTER)
    answer.grid(row = 3,column=0)
    
    scoretxt = Label(root,text ="Your score is:",bg = "light green", width = 38)
    scoretxt.grid(row = 10,column = 0, sticky = W)
    
    ### make a submit button
    Button(root,text= "Submit",bg = "light grey",command = submit_button_clicked).grid(row = 4,column = 0, sticky = W)
    
    root.mainloop()
    


Answer: This should work. I added a `try` statement in the function
`submit_button_clicked()` so if the question was the last one it would still
update the score. If you read through the code you should see what I changed.
Let me no if you don't understand it. Have a great day!

    
    
    from tkinter import *
    
    root = Tk()
    root.title("End of year exam")
    
    score = 0
    
    questions =[("What does 13 + 5 = ?","18"),("What does 12 + 8 = ?","20"),("What does 19 + 6 = ?","25"),("What does 17 + 15 = ?","32")]
    
    current_question = 0
    
    def submit_button_clicked():
        global score
        global questions
        global current_question
    
        if answer.get() == questions[current_question][1]:
            score += 1
            current_question += 1
            try:
                question.config(text=questions[current_question][0])
            except:
                pass
            answer.delete(0, 'end')
        scoretxt.config(text = "Your score is: {}".format(str(score)))
    
    
    
    
    Label(root,text = "Question : ",bg ="light grey").grid(row = 0,column = 0, sticky = W)
    question=Label(root,bg = "light green",text=questions[current_question][0], width = 38)
    question.grid(row =1,column=0)
    
    Label(root,text = "Answer: ",bg = "light grey").grid(row = 2, column = 0, sticky = W)
    answer = Entry(root,bg ="white",width = 45, justify = CENTER)
    answer.grid(row = 3,column=0)
    
    scoretxt = Label(root,text ="Your score is:",bg = "light green", width = 38)
    scoretxt.grid(row = 10,column = 0, sticky = W)
    
    ### make a submit button
    Button(root,text= "Submit",bg = "light grey",command = submit_button_clicked).grid(row = 4,column = 0, sticky = W)
    
    root.mainloop()
    

