-1

Calculating days between two datetimes, I have:

import datetime

...
days_late = curr_date-last_date
diff_days = days_late.days
print(diff_days)

which prints -9

Then I try to format the output using:

print("Days left: {}").format(diff_days)

I get AttributeError: 'NoneType' object has no attribute 'format'

How can I fix it?

xain
  • 13,159
  • 17
  • 75
  • 119

2 Answers2

0

You just need to format the string not the print.

print("Days left: {}".format(diff_days))
ThRnk
  • 575
  • 2
  • 19
0

you are trying to use the format generator on the print() function. instead use

print("Days left: {}".format(diff_days)).

The.B
  • 361
  • 2
  • 11