# Note: your assignments should have docstring # comments. They are not here so the program can # be more easily displayed during class. # def validateInput(inputString): ans = input(inputString) isSure = input("Are you sure that is correct? Enter yes or no: ") while isSure != 'yes': ans = input("Please try again: ") isSure = input("Are you sure that is correct? Enter yes or no: ") return ans def getAmount(expense): return float(validateInput("Enter the amount you pay for " + expense + " in the form xx.yy: ")) def getTimes(): return int(validateInput("Now please enter the number of times per yer this cost is incurred.: ")) def getPrintExpenses(expenses): annualCosts = 0 for e in expenses: annualCosts += getAmount(e) * getTimes() print("Your total monthly cost is $",format(annualCosts / 12,",.2f"),sep = "") print("Your total annual cost is $",format(annualCosts,",.2f"),sep = "") def main(): expenses = ["loan payment", "insurance", "gas", "oil","maintanence"] getPrintExpenses(expenses) main()