Python grand finale error

I am trying to learn the python grand finale problem. It seems like my code should work but it just gives me the “Oops something went wrong” error. Can someone point out why the following code doesn’t print the date and time.

from datetime import datetime

now = datetime.now()

print ‘%02d/%02d/%04d %02d:%02d:%02d’ % (now.month, now.day, now.year, now.hour, now.minute, now.second)

I put a ( and ) so that the print works in Python 3.
It seems to work fine.

from datetime import datetime now = datetime.now() print( '%02d/%02d/%04d %02d:%02d:%02d' % (now.month, now.day, now.year, now.hour, now.minute, now.second) )

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.