在代碼中,我需要將“age”加一,并且“age”需要從 24 開始。我正在考慮創建另一個函式,該函式將輸入 def getResults 并從該函式中將“age”加一。不知道該怎么做。對此很陌生。請幫忙。謝謝!
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)
uj5u.com熱心網友回復:
這是你想要的 ?
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)
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/440166.html
