试图在#6 创建的列表的#7 中对角求和。所以说列表是这样[[2,3,1],[1,1,1],[5,6,4]]
的,总和是 2+1+4
#6
def randomlists(s):
b=s
list1 = []
while s>0:
sublist = []
for x in range(0,b):
sublist.append(randrange(-100,101))
list1.append(sublist)
s-=1
return list1
#print(randomlists(5))
#7
def diagonalsum(x):
a=randomlists(x)
count=0
print (a)
for b in a:
while count<x:
d=a[0]
b=a[1]
c=a[2]
print (a[(count)])
count+=1
return d+b+c
print (diagonalsum(3))