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:]ifdirection == -1:
tmp = tmp[::-1]foriinrange(len(tmp)):
res[i] += tmp[i]direction *= -1print(*res, sep='\n')
Comments