Date and Time Grand Finale Help


#1

Hello,

I am confused as to why I am receiveing a syntax error after correctly following these instructions:

Print the date and time together in the form: mm/dd/yyyy hh:mm:ss.

To start, change the format string to the left of the % operator.

Ensure that it has 6 %s placeholders.
Put slashes and colons and a space between the placeholders so that they fit the format above.

Then, change the variables in the parentheses to the right of the % operator.

Place the variables so that now.month, now.day, now.year are before now.hour, now.minute, now.second. Make sure that there is a ( before the six and a ) after them.

Here is the code I put according to the instructions:

from datetime import datetime
now = datetime.now()

print '%s/%s/%s %s:%s:%s' % (now month, now day, now year, now.hour, now.minute, now.second)

Yet, in my interpreter, I'm getting this error:

File "python", line 4
print '%s/%s/%s %s:%s:%s' % (now month, now day, now year, now.hour, now.minute, now.second)
^
SyntaxError: invalid syntax

Can anyone explain this to me? Its odd that I'm getting an error and I did the right instructions.

Thanks for the help :smiley:

https://www.codecademy.com/en/courses/python-beginner-en-zFPOx/0/6?curriculum_id=4f89dab3d788890003000096#


#2

Never mind, I figured it out, thanks anyway ;D

May Python be with you! lol!


#3

Remember to write these as attributes of an object.

now.month

and so on...


#4

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