Commit bde0d58f by 大雄

z字行变换作业

parents
class solution:
# step = 1
def convert(self, s, numrow):
if numrow == 1:
return s
L=['']*numrow
step = 1
index = 0
if numrow >=1:
for x in s: # for循环后面有冒号:
L[index] = L[index] + x
if index == 0:
step = 1
elif index == numrow-1:
step = -1
index += step
return ''.join(L)
sol = solution()
s = "LEETCODEISHIRING"
numrow = 4
sol.convert(s, numrow)
print(sol.convert(s, numrow))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment