# Python How to print the values that are more than average income? Average income works fine but more than average income is getting an error, def find_all(): stocks = [] for child in...

# Python How to print the values that are more than average income? Average income works fine but more than average income is getting an error, def find_all(): stocks = [] for child in root.iter("property"): data = child.attrib.copy() data["cost"] = string_to_float(data["cost"]) data["downPayment"] = string_to_float(data["downPayment"]) data["percentage"] = string_to_float(data["percentage"]) data["netIncome"] = string_to_float(child.text) stocks.append(data) return stocksdef average_income(): averageIncome = find_all() averageIncome =sum([i['netIncome'] for i in averageIncome]) / len(averageIncome) return [{"averageIncome {:.2f}".format(averageIncome)}] def more_average_income(): average = average_income()[0]['averageIncome'] more_than_avg =[x for x in find_all() if x['netIncome'] > average] return more_than_avg if __name__ == '__main__': print(average_income()[0]['averageIncome']) values = more_average_income() for v in values: print(v)

Jun 05, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here