(continued from previous page for complete overview of string formatting with str format()see formatstrings manual string formatting here' the same table of squares and cubesformatted manuallyfor in range( )print(repr(xrjust( )repr( *xrjust( )end='note use of 'endon previous line print(repr( * *xrjust( ) (note that the one space between each column was added by the way print(worksit always adds spaces between its arguments the str rjust(method of string objects right-justifies string in field of given width by padding it with spaces on the left there are similar methods str ljust(and str center(these methods do not write anythingthey just return new string if the input string is too longthey don' truncate itbut return it unchangedthis will mess up your column lay-out but that' usually better than the alternativewhich would be lying about value (if you really want truncation you can always add slice operationas in ljust( )[:nthere is another methodstr zfill()which pads numeric string on the left with zeros it understands about plus and minus signs' zfill( ' '- zfill( '- ' zfill( ' old string formatting the operator can also be used for string formatting it interprets the left argument much like sprintf()style format string to be applied to the right argumentand returns the string resulting from this formatting operation for example input and output