import numpy as np def count(row,colum): num=0 for i in range(row): for j in range(colum): if A[i][j] == 'W': num += 1 return num #入力ゾーン A = np.array([['W','W','R','W'], ['W','R','W','W'], ['W','W','W','R']]) #出力ゾーン print('塗る回数',count(A.shape[0],A.shape[1]))