-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path6.py
39 lines (39 loc) · 1.18 KB
/
6.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
def convert(s, numRows):
lista=[]
i=0
string=''
times=True
if numRows==1:
return s
while i<len(s):
alist=[]
if times==True:
for j in range(numRows):
if i<len(s):
alist.append(s[i])
i+=1
else:
break
cnt=numRows-1
else:
for j in range(numRows):
if i<len(s):
if j==cnt:
alist.append(s[i])
i+=1
else:
alist.append('')
else:
break
while len(alist)<numRows:
alist.append('')
lista.append(alist)
if cnt==1:
times=True
else:
times=False
cnt-=1
for j in range(numRows):
for i in range(len(lista)):
string+=lista[i][j]
return string