My variable is defined but python is saying it isn't?
<p>I keep getting an error telling me that the name <code>hourly_pay</code> is not defined, but I have it defined inside the <code>main</code> function. </p>

<p>I'm a beginner as I've just started class but to me it looks like it should be working:</p>

<pre><code>commission_pay_amount = .05
income_taxes = .25
Pay_per_hour = 7.50

def main():
    display_message()

    hourly_pay = float(input('Please enter amount of hours worked: '))

    commission_pay = hourly_pay * commission_pay_amount
    gross_pay = hourly_pay + commission_pay 
    witholding_amount = gross_pay * income_taxes  
    hourly_paying = Pay_per_hour * hourly_pay
    net_pay = gross_pay - witholding_amount

    display_results()

def display_message():
    print('This program is used to calculate')
    print('the hourly pay, commission amount,')
    print('the gross pay, the withholding amount,')
    print('and the net pay amount')
    print()

def display_results():
    print('The hourly pay is $', format(hourly_pay, ',.2f'))
    print('The commission amount is $', format(commission_pay, ',.2f'))
    print('The gross pay is $', format(gross_pay, ',.2f'))
    print('The witholding amount is $', format(witholding_amount, ',.2f'))
    print('The net pay is $', format(net_pay, ',.2f'))

main()
</code></pre>

<p><code>hourly_paying</code> is defined in <code>main()</code> and it stays in main's scope. You need to pass it to <code>display_results</code> and modify <code>display_results</code> to accept all the values that you need. For example:</p>

<pre><code>commission_pay_amount = .05
income_taxes = .25
Pay_per_hour = 7.50


def main():

    display_message()

    hourly_pay = float(input('Please enter amount of hours worked: '))


    commission_pay = hourly_pay * commission_pay_amount
    gross_pay = hourly_pay + commission_pay
    witholding_amount = gross_pay * income_taxes
    hourly_paying = Pay_per_hour * hourly_pay
    net_pay = gross_pay - witholding_amount

    display_results(hourly_paying,commission_pay,gross_pay,witholding_amount,net_pay)

def display_message():
    print('This program is used to calculate')
    print('the hourly pay, commission amount,')
    print('the gross pay, the withholding amount,')
    print('and the net pay amount')
    print()

def display_results(hourly_paying,commission_pay,gross_pay,witholding_amount,net_pay):
    print('The hourly pay is $', format(hourly_paying, ',.2f'))
    print('The commission amount is $', format(commission_pay, ',.2f'))
    print('The gross pay is $', format(gross_pay, ',.2f'))
    print('The witholding amount is $', format(witholding_amount, ',.2f'))
    print('The net pay is $', format(net_pay, ',.2f'))

main()

input ('Press ENTER to continue....')
</code></pre>

python variables scope nameerror