Nov-14-2018, 04:59 PM
def main(): customer_age = customer_age_selection() insurance_response = input_insurance_response() insurance_weekly_coverage = insurance_process (insurance_response,customer_age) print_output(insurance_weekly_coverage,insurance_daily_coverage) # get customer age def customer_age_selection(): selection_is_invalid = True while selection_is_invalid: print() customer_age = int(input("Enter your age: ")) print() if customer_age < 18 or customer_age > 95: print ("age number inputed is invalid; re-enter your age: ") else: selection_is_invalid = False print() print ("Request is invalid please, re-enter your requested age") return customer_age # get insurance response def input_insurance_response(): print() print ("The following are the insurance rates:") print("Age Of Driver Daily Coverage Weekly Coverage") print("18 to 25 $7 $40 ") print("26 to 40 $5 $30 ") print("Over 40 $3 $15 ") print() selection_is_invalid = True while selection_is_invalid: insurance_response = input("Do you want insurance?: ") if insurance_response == "yes": insurance_response = True selection_is_invalid = False elif insurance_response == "no": insurance_response = False selection_is_invalid = False else: selection_is_invalid = True print ("Please enter yes or no: ") print() return insurance_response def insurance_process(insurance_response,customer_age): if insurance_response == "yes" and customer_age < 20 or customer_age > 25: insurance_daily_coverage = 7 insurance_weekly_coverage = 40 elif insurance_response == "yes" and customer_age < 26 or customer_age > 40: insurance_daily_coverage = 5 insurance_weekly_coverage = 30 return insurance_weekly_coverage,insurance_daily_coverage def print_output(insurance_weekly_coverage): print("",insurance_weekly_coverage,"") main()the program is simple it takes input as age returns to main and yes or no response and returns to main, im calling the insurance_process function
and getting an error:UnboundLocalError: local variable 'insurance_weekly_coverage' referenced before assignment
is insurance_weekly_coverage = insurance_process (insurance_response,customer_age) an asssigment?