```
class Solution(object):
def convert(self, s, numRows):
"""
:type s: str
:type numRows: int
:rtype: str
"""
if numRows==1:
return s
A=[[] for i in range(numRows)]
B=list(range(numRows))+list(range(numRows-2,0,-1))
r=2*numRows-2
j=0
for i,c in enumerate(s):
i=i%r
A[B[i]].append(c)
res=[]
for i in range(numRows):
res.extend(A[i])
return ''.join(res)
```