[Tutor] Cosmetic question about printing

Kent Johnson kent37 at tds.net
Wed May 7 02:41:37 CEST 2008


On Tue, May 6, 2008 at 5:41 PM, Dick Moores <rdm at rcblue.com> wrote:

>
> The function is now:
>
>
> def printResult(date1, date2, days1, weeks, days2):
>     print "\nThe difference between %s and %s is %d days" % (date1.strftime("%m/%d/%Y"),
>         date2.strftime("%m/%d/%Y"), days1)
>     line1 = "\nThe difference between %s and %s is %d days" % ((date1.strftime("%m/%d/%Y"), date2.strftime("%m/%d/%Y"), days1))

There is no need to compute this string twice, just use
  line1 = ...
  print line1

Kent


More information about the Tutor mailing list