Check whether a matrix is lower triangle or not

 m=int(input("Size of matrix"))

a=[]

for i in range(m):

    a.append([int(j) for j in input().split()])  

flag=0

for i in range(len(a)):

    for j in range(i+1,len(a)):

        if a[i][j]!=0:

            flag=1

            break

        

if flag:

    print("not Lower")

else:

    print("Lower traingle")

No comments:

Post a Comment