'incrementing array value by one in python
In the code, I need to increment "age" by one, and "age" needs to start at 24. I was thinking of making another function that would feed into def getResults and increment "age" by one from that function. Don't know how to do that. New to this. Please help. Thanks!
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)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
