【发布时间】:2021-09-03 13:56:30
【问题描述】:
def count(matrix: list, number: int):
count([[1, 4, 0, 0, 6, 3], [0, 3, 4, 0, 0, 0], [0, 0, 5, 6, 0]], 0)
我正在尝试创建计算矩阵列表中的所有零或任何其他数字但现在为 0 的函数。
【问题讨论】:
-
因为你的输入列表只包含没有一个等于0的列表。你需要先flatten it
-
那么你的代码现在是什么样子的?
-
另外,这是否回答了您的问题? python .count for multidimensional arrays (list of lists)
标签: python list function matrix counting