even though my output is same as testcase output hackerrank shows error

43 views Asked by At

my code in python for the problem matrix-script in hackerrank https://www.hackerrank.com/challenges/matrix-script/problem?isFullScreen=false ( link for the problem in hackerrank ) and here is code

first_multiple_input = input().rstrip().split()
n = int(first_multiple_input[0])
m = int(first_multiple_input[1])
matrix = []

for _ in range(n):
    matrix_item = input()
    matrix.append(matrix_item)
temp=''
for i in range(m):
    for j in range(len(matrix)):
        temp+=matrix[j][i]
i=0
while i<len(temp):
    if (not temp[i].isalnum())and(i!=0):
        if temp[i-1].isalnum():
            for j in range(i,len(temp)):
                if temp[j].isalnum():
                    temp=temp[:i]+' '+temp[j:]
                    break
            i=j-1
    i=i+1
print(temp)

output in image

0

There are 0 answers