其他分享
首页 > 其他分享> > pyhton3 出错求大佬帮忙!IndexError: list index out of range

pyhton3 出错求大佬帮忙!IndexError: list index out of range

作者:互联网

def society(graph_matrix,person):
i=0
I=0
a=[]
b=[]
x=int(person)
n=len(graph_matrix)
while i <= n:
for j in range(n):
if sum(graph_matrix[x])>=2:
if graph_matrix[x][j]==1:
a.append(j)
else:
print(False)
i=i+1
while I <= len(a):
for J in range(0,len(a)):
if graph_matrix[a[I]][a[J]]==1:
b.append(1)
else:
b.append(0)
I=I+1
if sum(b)>0:
print(True)
else:
print(False)

clayton_matrix = [ [0,1,1,1,0],
[1,0,0,1,0],
[1,0,0,0,1],
[1,1,0,0,0],
[0,0,1,0,0] ]
print(society(clayton_matrix,0))

标签:index,IndexError,matrix,graph,list,else,range,print,append
来源: https://blog.csdn.net/ktan0070/article/details/100079516