如何找到嵌套循环中的数字列表的总和?
s=0
people=eval(input())
for i in range(people):
firstn=input()
lastn=input()
numbers=(eval(input()))
print(firstn, lastn, numbers)
for b in range(numbers):
numbers=eval(input())
s+=numbers
print(b)
输入如下:
5 #nubmer of people I need to calculate
Jane #firstname
Doe #lastname
4 #number of floats for each person, pretty sure this is for the second loop
38.4 #these are the floats that i need to calculate for each person to find their sum
29.3
33.3
109.74
William #loop should reset here as this is the next person's first name
Jones
2
88.8
99.9
firstname
lastname
number of floats
float1
float2...
我需要找到如何计算每个循环的不确定数字的总和,我现在遇到的问题是循环没有为每个人重置每个值,我得到了一个总和。