0 1 0 x x 1 y x
import numpy as np import pandas as pd n=int(input('Give value of n size of the matrix : ')) arr=np.zeros([n,n]) df=pd.DataFrame(arr) print(df) rows = n col = n num=rows*col b=input('First character: ') d=input('Second charater: ') i=1 while i<=num: e=int(input('enter row no.:')) f=int(input('enter col no.:')) choice = input('Which character do you want to enter : ') if choice!=b and choice!=d: print('Enter correct charcters') choice = input('Which character do you want to enter : ') if df.iat[e,f]!=0: print('position is filled! give different coordinates') e=int(input('enter row no.:')) f=int(input('enter col no.:')) df.iat[e,f]=choice print(df) i+=1 for a in range(2,n+1): for j in range(0,n-a+1): if df.iat[j,j]==df.iat[j,j+a-1] and df.iat[j,j]==df.iat[j+a-1,j] and df.iat[j,j]==df.iat[j+a-1,j+a-1]: z=1 if z==1: print('matrix not allowed')
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)