Hi, I am new to writing code and am doing a programming assignment for a class that has to be separated into different functions. I figured most of it out, but can't seem to get the validation part to work at all. could someone with more experience than me please check the get_info function and tell me what I am doing wrong. Thanks for your help.

def main():

    hours, rate = get_info()

    base, over = calc_hours(hours)

    pay1, pay2, total = calc_pay(rate, base, over)

    print()
    print('      Payroll Information')
    print('Pay Rate                 $', format(rate,  ',.2f'), sep='')
    print('Regular Hours            ',  format(base,  ',.2f'))
    print('Overtime Hours           ',  format(over,  ',.2f'))
    print('Regular Pay              $', format(pay1,  ',.2f'), sep='')
    print('Overtime Pay             $', format(pay2,  ',.2f'), sep='')
    print('Total Pay                $', format(total, ',.2f'), sep='')

def get_info():

    hours = 0
    rate  = 0

    hours = float(input('Enter total hours worked: '))
    while hours < 8 and hours > 86:
        print('ERROR!!! --- Hours must be between 8 and 86')
        hours = float(input('Enter again: '))

    rate  = float(input('Enter payrate: $'))
    while rate < 7.00 and rate > 50.00:
        print('ERROR!!! --- Rate must be between $7.00 and $50.00')
        rate = float(input('Enter again: '))

    return hours, rate        

def calc_hours(hours):

    base = 40
    over = 0

    if hours > 40:
        over = hours - base
    else:
        base = hours

    return base, over

def calc_pay(rate, base, over):

    pay1 = 0
    pay2 = 0

    pay1 = base * rate
    pay2 = over * (rate * 1.5)
    total = pay1 + pay2

    return pay1, pay2, total

main()

Figured it out. I needed to change the 'ands' to 'ors'.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.