zigzag conversion python