Question asked is:
Read a string of length 15, read r and c integers such that r*c=15, arrange the elements of string in form of a matrix which has r rows and c columns.
sample input
goodprogrammer!
3
5
sample output:
g o o d p
r o g r a
m m e r !
My code :
s=str(input())
r=int(input())
c=int(input())
if len(s) != 15:
print('invalid input')
else:
if r*c != 15:
print ('invalid input')
else:
i=0
for element in s:
print(element,"",end="")
i=i+1
if i%c == 0:
print()
My output is same as the sample output when I entered input same as sample input. but my code didnt pass. can anyone tell me what's wrong?
Thanks!