Skip to main content
Improve code style for readability. Mention that this is for Python 2, for any beginners.
Source Link
wjandrea
  • 33.8k
  • 10
  • 69
  • 105

How about this (for Python 2):

strings = [x.split() for x in [a, b, c]]
just = max([len(x[0]) for x in strings])
for string in strings:
    print string[0].ljust(just),
print
for string in strings:
    print string[1].ljust(just),

How about this:

strings = [x.split() for x in [a, b, c]]
just = max([len(x[0]) for x in strings])
for string in strings: print string[0].ljust(just),
print
for string in strings: print string[1].ljust(just),

How about this (for Python 2):

strings = [x.split() for x in [a, b, c]]
just = max([len(x[0]) for x in strings])
for string in strings:
    print string[0].ljust(just),
print
for string in strings:
    print string[1].ljust(just),
Source Link
zipa
  • 28k
  • 6
  • 45
  • 62

How about this:

strings = [x.split() for x in [a, b, c]]
just = max([len(x[0]) for x in strings])
for string in strings: print string[0].ljust(just),
print
for string in strings: print string[1].ljust(just),