我有一个可以在我的计算机上运行的代码,但是在其他返回值上,max()arg是一个空序列错误(在max_x_value行中)。不知道如何在笔记本电脑上正常工作时调试它(而且我没有经验,所以...)
def parts(inp,partnumber):
"transpone input to part"
tuples = [(inp[i], inp[i+1]) for i in range(0, len(inp), 2)]
# defines matrix dimensions
max_x_value = max([i[0] for i in tuples])+1
max_y_value = max([i[1] for i in tuples])+1
# Creates matrix - with 0 everywhere
res_matrix = [[0 for _ in range(max_y_value)] for _ in range(max_x_value)]
# goes through tuple and inserts part numbers at it's place
for i in tuples:
res_matrix[i[0]][i[1]]=partnumber
# rotates matrix 90
res = list(map(list, list(zip(*res_matrix))[::-1]))
return res # [[0, 0, 1], [1, 0, 1], [1, 1, 1]]