"format() takes no keyword arguments" error


#1

Hello, I'm trying to get this program to run, but I'm stuck with the following error:
"format() takes no keyword arguments"

I'm trying to have the results displayed, and have been tinkering with it to no avail.
Thanks in advance.


HOURLY_PAY_RATE  = 7.50
COMMISSION_RATE  = 0.05
WITHHOLDING_RATE = 0.25

def startup_message():
    print('''This program calculates the salesperson's pay.
Five values are displayed.
Hourly pay, commission, gross pay, withholding, and net pay.\n''')

def main():
    startup_message()
    name = input('Enter name: ')
    sales_amount = float(input('Enter sales amount: '))
    hours_worked = float(input('Enter hours worked: '))

    hourly_pay = hours_worked * HOURLY_PAY_RATE
    commission_amount = sales_amount * COMMISSION_RATE
    gross_pay = HOURLY_PAY_RATE + COMMISSION_RATE
    withholding = gross_pay * WITHHOLDING_RATE
    net_pay = gross_pay - withholding

    show_hourly_pay(hourly_pay) #<--------------- 
    show_commission_amount(commission_amount)#<-- Are these needed? \
    show_gross_pay(gross_pay) #<----------------- Do they need to be \
    show_withholding(withholding) #<------------- defined individually \
    show_net_pay(net_pay)#<---------------------- below?

    
def show_hourly_pay(hourly_pay):
    print('Hourly pay amount is: $', \
          format(hourly_pay, ',.2f', \
          sep=''))
def show_commission_amount(commission_amount):
    print('Commission amount is: $', \
          format(commission_amount, ',.2f', \
          sep=''))
def show_gross_pay(gross_pay):
    print('Gross pay is: $', \
          format(gross_pay, ',.2f', \
          sep=''))
def show_withholding(withholding):
    print('Withholding amount is: $', \
          format(withholding, ',.2f', \
          sep=''))
def show_net_pay(net_pay):
    print('Net pay is: $', \
          format(net_pay, ',.2f', \
          sep=''))
    
main()
input('\nPress ENTER to continue...')


#2

@twenty_three please specify the chapter no and lesson name ..


#3

you might want to check documentation on .format, you need to use a . not a ,:

print("test {}".format("sentence"))

@ronit1710, it is not exercise related, this is clearly python3 syntax, codecademy is python2


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.