我这个代码是没有问题的,就想问一下,如果将这个代码中的输入input该用format函数,怎么改,麻烦看一下,谢谢
def main():
"""Display income report for incomes over a given number of months."""
incomes = []
months = int(input("How many months? "))
for month in range(1, months + 1):
income = float(input("Enter income for month " + str(month) + ": "))
incomes.append(income)
print("\nIncome Report\n-------------")
total = 0
for month in range(1, months + 1):
income = incomes[month - 1]
total += income
print("Month {:2} - Income: ${:10.2f} Total: ${:10.2f}".format(month, income, total))
main()