LearnPy Hub
← Introduction & print() problems
Hard

Write a Word in a Zigzag

Read a word and a number of rows k. Write the word's letters going down rows 1..k, then up to row 1, and so on. Print each row, putting every letter in its own column (spaces elsewhere) and removing trailing spaces.

Input

A word, then k ≥ 2.

Output

k lines.

Sample 1

Input
PROGRAMMING
3
Output
P   R   I
 R G A M N
  O   M   G

Sample 2

Input
python
2
Output
p t o
 y h n
solution.py
Output appears here
Write a Word in a Zigzag · Python practice problem · LearnPy Hub