def is_prime(a): x = True for i in range(2, a): if a%i == 0: x = False break if a<2: x = False return x def ReadMAtrix(R,C): matrix = [] print("Enter the entries rowwise:") for i in range(R): a = [] for j in range(C): a.append(int(input())) matrix.append(a) return matrix R = int(input("Enter the number of rows:")) C = int(input("Enter the number of columns:")) Mat=[] Mat=ReadMAtrix(R,C) print('prime in matrix : ') for i in range(R): for j in range(C): if is_prime(Mat[i][j]) : print(Mat[i][j], end=" ")