On Tue, May 6, 2008 at 11:40 AM, Dick Moores <[EMAIL PROTECTED]> wrote: > > > > > At 09:07 AM 5/6/2008, Kent Johnson wrote: > > You can right-justify in a format operation. You will have to do it in > two steps since the string you want to right-justify is itself the > result of a format operation: > line2 = "Or %d weeks and %d days" % (weeks, days2) > print '%50s' % line2 > > Instead of 50 you probably want to use the length of the previous > line. You can insert this into the format using * for the length: > print %*s' % (len(line1), line2) > print "This is a very very long line ending in %s" % "even more length" > print "A short %s" % "line"
I think it would consist of line1 = "This is a very very long line ending in %s" % "even more length" line2 = "A short %s" % "line" print line1 print '%*s' % (len(line1), line2) In a function: >>> def foo(string1, string2): ... print string1 ... print '%*s' % (len(line1), line2) ... >>> foo(line1, line2) This is a very very long line ending in even more length A short line (as close as I can get it with non-monospace) -Wayne _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor