在 python 中将数组值递增 1

incrementing array value by one in python

在代码中,我需要将“age”递增 1,而“age”需要从 24 开始。我正在考虑制作另一个函数,该函数将输入 def getResults 并将“age”递增 1那个功能。不知道该怎么做。对此很陌生。请帮忙。谢谢!

import pprint


def getResults():
    mylist = []
    for n in range(1, 37 + 1):
        currentRow = {"age": n, "numOfYears": n,
                      "beginningBalance": n, "currentSalary": 72_000.00,
                      "dividendsAndGrowth": n, "yearlyDeposit": 8_640.00,
                      "yearlyTotal": n}
        mylist.append(currentRow)

    return mylist


if __name__ == "__main__":
    z = getResults()
    pprint.pprint(z)

这是您要找的吗?

import pprint


def getResults():
    mylist = []
    for n in range(1, 37 + 1):
        currentRow = {"age": 23+n, "numOfYears": n,
                      "beginningBalance": n, "currentSalary": 72_000.00,
                      "dividendsAndGrowth": n, "yearlyDeposit": 8_640.00,
                      "yearlyTotal": n}
        mylist.append(currentRow)

    return mylist


if __name__ == "__main__":
    z = getResults()
    pprint.pprint(z)