def count(element, m):
cnt = 0
for i in range(len(m)):
for j in range(len(m[i])):
if m[i][j] == element:
cnt += 1
return cnt
matrix = [[1,8,4],[2,6,9],[7,2,3]]
print(count(7, matrix)) # вывод: 1
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
def count(element, m):
cnt = 0
for i in range(len(m)):
for j in range(len(m[i])):
if m[i][j] == element:
cnt += 1
return cnt
matrix = [[1,8,4],[2,6,9],[7,2,3]]
print(count(7, matrix)) # вывод: 1