gpt4 book ai didi

python - 没有numpy的矩阵转置,错误: list index out of range

转载 作者:行者123 更新时间:2023-12-05 08:14:23 33 4
gpt4 key购买 nike

<分区>

我想做矩阵的转置。我不想使用 numpy。我收到以下错误(代码下方)。感谢任何帮助

    matrix = [[1,2,3],[1,2,3],[1,2,3],[1,2,3],[1,2,3],[1,2,3],[1,2,3]]

transposed = []

for i in range(7):
new=[]
for row in matrix:
new.append(row[i])
transposed.append(lst)
print(transposed)

错误:

---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
<ipython-input-106-856d3ec27942> in <module>()
6 new=[]
7 for row in matrix:
----> 8 new.append(row[i])
9 transposed.append(lst)
10 print(transposed)

IndexError: list index out of range

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com