I just learned from this answer this answer I can use format
with a list:
li = [2, 3, 5, 7, 11]
print '{0} {2} {1} {4}'.format(*li) # => 2 5 3 11
Now I want to justify every element of a list. What I'm doing is:
print "{0:>12}{1:>12}{2:>12}{3:>12}".format(*PROPERTIES)
However, this isn't really convenient as the list may get larger. I am curious is this possible by using only print
and format
(no loops)?