Answer to Question #333064 in Python for Ajay

Question #333064

Question



Convert the given word in to snaky conversion according to the number (N)




Example:-



Input



AWESOMENESS 4




Explanation:-



A. E



W. M. N



E. O. E. S



S. S




Output :-



AE



WMN



EOES



SS





1
Expert's answer
2022-04-24T17:16:17-0400
s = input()
s, n = s.split()
n = int(n)
res = ["" for i in range(n)]
direction = 1
while s:
    tmp = s[:n]
    s = s[n:]
    if direction == -1:
        tmp = tmp[::-1]
    for i in range(len(tmp)):
        res[i] += tmp[i]
    direction *= -1
print(*res, sep='\n')

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS