Function Problems and Local Variables
<p>I am learning Python and am making a Q&amp;A script.  I made one function for the questions.  That went rather well.  Now I am wanting an average function.  I want to avoid using globals if at all possible.  I know that my variables reset at the top... can someone please give me some pointers?  I know C/PHP/BASIC and want to grasp this langauge.  Below is my question function.</p>

<pre><code>    def q(question, a, b, c, c_answer):
        total,tally=0,0
        print "",question
        print "   a.",str(a)
        print "   b.",str(b)
        print "   c.",str(c)
        u_answer = raw_input()
        if c_answer == "a" and u_answer == "a":
            print "Correct, the answer is A!"
            tally+=1
        elif c_answer == "b" and u_answer == "b":
            print "Correct, the answer is B!"
            tally+=1
        elif c_answer == "c" and u_answer == "c":
            print "Correct, the answer is C!"
            tally+=1
        else:
           print "I am sorry, but the correct answer is",c_answer
        print "\..n"
        total+=1
</code></pre>
