Created
March 26, 2013 13:20
-
-
Save dxlbnl/5245302 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resp_lines = [ | |
str(range(i)) for i in range(20, 50,3) | |
] | |
width = 80 | |
space = " " | |
""" | |
The proper way ? | |
""" | |
new_resp_lines = [] | |
for line in resp_lines: | |
_space = '' | |
lns = [] | |
if len(line) > width: | |
while len(line) > (width - len(_space)): | |
lns.append(_space + line[:(width - len(_space))]) | |
line = line[(width - len(_space)):] | |
_space = space | |
lns.append(_space + line) | |
new_resp_lines += lns | |
else: | |
new_resp_lines.append(line) | |
""" | |
The improper way ? | |
""" | |
for i, line in enumerate(resp_lines): | |
if len(line) > width: | |
resp_lines[i:i+1] = [ | |
line[0:width], | |
space + line[width:] | |
] | |
print '\n'.join(new_resp_lines) | |
print "_______" | |
print '\n'.join(resp_lines) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment