-
Notifications
You must be signed in to change notification settings - Fork 0
/
zigzag.py
52 lines (31 loc) · 813 Bytes
/
zigzag.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
a=input()
a=a[1:len(a)-1]
print(a)
b=int(input())
l=[[ 0 for _ in range(len(a)) ] for _ in range(b)]
t=b-2
#row=b
#col=len(a)
x=0
ex=0
for i in range(len(a)):
if(ex==1):
break
for j in range(b):
#print(x)
if(x==len(a)):
ex=1
elif(i==0 or (i)%(b-1)==0):
l[j][i]=a[x]
x+=1
else:
if(t==0):
t=b-2
if(j==t):
l[j][i]=a[x]
x+=1
t-=1
for i in range(b):
for j in range(len(a)):
print(l[i][j],end="")
print()