Why am I getting "UnboundLocalError" in my code?
<p>I have revised the quotations to fix the syntax error. Now the error that I am receiving is this one:</p>

<pre><code>Traceback (most recent call last):
  File "C:\Users\Alex\Desktop\Programming Concepts\Labs\Chapter 11\Lab 8.py", line 78, in &lt;module&gt;
    main()
  File "C:\Users\Alex\Desktop\Programming Concepts\Labs\Chapter 11\Lab 8.py", line 18, in main
    totalPints = getTotal(pints)
  File "C:\Users\Alex\Desktop\Programming Concepts\Labs\Chapter 11\Lab 8.py", line 42, in getTotal
    totalPints += pints[counter]
  UnboundLocalError: local variable 'totalPints' referenced before assignment
</code></pre>

<p>Here is my code so far:</p>

<pre><code># Lab 8-3 Blood Drive

# The main function
def main():
    endProgram = 'no'
    print
    while endProgram == 'no':
        print
        # Declare variables
        pints = [0] * 7

        # Function calls
        pints = getPints(pints)
        totalPints = getTotal(pints)
        averagePints = getAverage(totalPints)
        highPints = getHigh(pints)
        lowPints = getLow(pints)
        displayInfo(averagePints, highPints, lowPints)

        endProgram = input('Do you want to end program? (Enter no or yes): ')
        while not (endProgram == 'yes' or endProgram == 'no'):
            print('Please enter a yes or no')
            endProgram = input('Do you want to end program? (Enter no or yes): ')

# The getPints function
def getPints(pints):
    counter = 0
    while counter &lt; 7:
        numEntered = input('Enter pints collected: ')
        pints[counter] = int(numEntered)
        counter += 1
    return pints

# The getTotal function
def getTotal(pints):
    counter = 0
    while counter &lt; 7:
        totalPints += pints[counter]
        counter += 1
    return totalPints

# The getAverage function
def getAverage(totalPints):
    averagePints = float(totalPints) / 7
    return averagePints

# The getHigh function
def getHigh(pints):
    highPints = pints[0]
    counter = 1
    while counter &lt; 7:
        if pints[counter] &gt; highPints:
            highPints = pints[counter]
        counter += 1
    return highPints

# The getLow function
def getLow():
    lowPints = pints[0]
    counter = 1
    while counter &lt; 7:
        if pints[counter] &lt; lowPints:\
           lowPints = pints[counter]
        counter += 1
    return lowPints

# The displayInfo function
def displayInfo(averagePints, highPints, lowPints):
    print('The average number of pints donated is ',averagePints)
    print('The highest pints donated is ', highPints)
    print('The lowest number of pints donated is ', lowPints)

# Calls main
main()
</code></pre>

<p>If anyone can copy and paste this code into their python and help troubleshoot it I would be greatful!</p>
