dimanche 3 mai 2015

How can I use a value that is already inside a "if" loop in another loop?

I am working on a program to build a quiz. I need to get my "true" out of the first loop in order to use it for the second.

As it is right now, Python says that "true" is not defined.

def verif(): #this is the function to check if answer was right
    y=(chosen_answer.get())
    true=0
    if chosen_answer==1:
       true=true+1
    else:
        true=true  #at the end true represents the number of correct answers

def final_count():
    if true==2:   #here it shows that "true" was not identified
        print("All of the answers were answered correctly!")
    elif true==1:
        print("50% were answered correctly")
    else:
        print("none of the answers were right..")

Aucun commentaire:

Enregistrer un commentaire