与矩阵及其位置斗争
我正在尝试解决这个程序(python),其中有一个矩阵,我应该显示每个行,每个位置和他的价值
我正在尝试这句话,但它不起作用:
m = [
[3, 8, 2],
[2, 3, 1],
[4, 2, 9]
]
for i in range(len(m)):
print('the row number',i+1,'and the position',m[0][i],'has a value of',m[i][0])
I am trying to solve this program (python) where having a matrix I should show every row, every position and his value
I am trying this sentence but it is not working:
m = [
[3, 8, 2],
[2, 3, 1],
[4, 2, 9]
]
for i in range(len(m)):
print('the row number',i+1,'and the position',m[0][i],'has a value of',m[i][0])
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该有一个嵌套循环以在每个原始和每个col上打印
:
You should have a nested loop to print on each raw and each col:
which gives