Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 39796

output same as expected output, but test fail!

$
0
0

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!


Viewing all articles
Browse latest Browse all 39796

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>