我希望能夠計算循環返回的'totalTimes'的總和。任何想法如何做到這一點?下面是代碼我目前有:循環結果求和
感謝
subjectsNum = int(input ("How many subjects do you have to study?"))
def subject():
for i in range (1, subjectsNum+1):
subjectName = input ("What is the subject name?")
pagesQuantity = float(input ("How many pages do you have to study?"))
pagesTime = float (input ("How long do you reckon it will take to study one page (in minutes)?"))
totalTime = (pagesQuantity) * (pagesTime)/60
print("The estimated time to study %s is %s hours" %(subjectName, totalTime))
subject()