code:
def calculateScore(scoreList):
scoreList=scoreList
i=0
total=0
while i<len(scoreList):
total+=scoreList[i]
if i>=len(scoreList)-3:
i+=1
continue
if scoreList[i]==10:
total+=scoreList[i+1]+scoreList[i+2]
i+=1
continue
i+=1
total+=scoreList[i]
if scoreList[i]+scoreList[i-1]==10:
total+=scoreList[i+1]
i+=1
return total
scoreLists = [
[2,3,4,4,6,2,1,0,2,4,5,2,9,0,1,1,3,4,2,2],
[2,3,4,6,6,2,1,0,2,4,5,2,9,0,1,1,3,4,2,2],
[2,3,4,6,10,1,0,2,4,5,2,9,0,1,1,3,4,2,2],
[2,3,4,6,0,10,1,0,2,4,5,2,9,0,1,1,3,4,2,2],
[10,10,10,10,10,10,10,10,10,10,10,10]
]
for x in scoreLists:
print(calculateScore(x))
output:
57
65
72
62
300
I think your output is wrong, I calculated it by hand to make sure too.