Date and Time 6/6


Hi, i was wondering if I am doing anything wrong.
from datetime import datetime
now =

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

please let me know :smile :smile:


you need to write it like this
print '%s/%s/%s %s:%s:%s' % (now.month,, now.year,now.hour, now.month, now.second,)

What you are writing is simply what they are showing you have learned so far.


I wrote exactly that and even copied and pasted what you had and it still doesn't work. Please help !


Hey, hope it's not too late.

# from datetime import datetime     looks up the time/date
# now =     sets the time/date equal to now.timepart

# print     prints the statement
# this '00/00/00 00:00:00' is our desired format, so replace each 00 with %s (don't forget quotes) to start your statement
# % replaces each %s with a variable
# (now.month,, now.year, now.hour, now.minute, now.second) is our list of variables

I'm not sure what exactly is going wrong with the suggested code, but it's very close to correct.


Hi I did this and it says invalid syntax. I still don’t understand syntax. Please help. (i.e.)
print '%s/%s/%s %s:%s:%s' % (now.month,, now.year,now.hour, now.month, now.second
thanks Nichola


Hi, @nicwo ,

Syntax relates to the rules for constructing statements in a language.

Did you close the parentheses in your statement?


Can you show us exactly what your code looks like, and the entire error message that's showing up?