Date and time grand finale


Oops, try again. Your printed date and time do not seem to be in the right format: mm/dd/yyyy hh:mm:ss

5/4/17 (7, 51, 53)

for the outcome to be 5/4/17 7:51:53

from datetime import datetime
now =

print '%s/%s/%s'% (5, 4, 17 ),  (7, 51, 53)



from datetime import datetime
now =

print '%s/%s/%s'% (5, 4, 17 ), (7, 51, 53)

This is your code.

Key thing here to understand is ,You don't need to put date manually but you have to make computer to do it for you.

Meaning of first two lines..

from datetime import datetime

Python have datetime module and a datetime function in it.
this datetime function have methods that will give you current date,time etc.

Next line..

now =

what is ?
for the time being imagine it's like a file that have information about time and date .
if you print now like this..
print now
then it will print this...
2017-05-04 12:12:39.539310

you can see that this variable have lots of information inside it..

like year,current month,current day,current hour,minute,second etc.

One cool thing to know that we can access all these info separately..

like this.. we use our predefined variable now

now.year ---> will give -- > 2017
now.month -- > will give month -- > 5

same way you can access minute,hour,second.

in this line you have to formate your date and time...

print '%s/%s/%s'% (5, 4, 17 ), (7, 51, 53)

so instead of 5,4 or anything you have to use now variable and access all those details and ..
also note that there are 6 variables so you need six string identifier(%s) this

print '%s/%s/%s figure this out' % (now.year, ?,?,?,?,?)

? part - you have to figure out by your own!
there are 5 ?'s to find.


sorrry I still dont really understand


Can you expain it a little more simply


I will refer you to revise previous exercise,this is the last exercise you're doing ? (of this section)


yeah this is the last one


If you revise last exercise then read what I wrote here ,then It may be more clear for you?
do that ,after doing that if it still does not make sense..I will explain :slight_smile:


ok cool:+1: i will thanks


ok I tried but I still didnt understand... sorry for bugging you too much btw.


sorry meant to reply to you not myself


from datetime import datetime
now =

Your first two lines are okay.

but...we have to make certain changes so it prompt right time and date..

print '%s/%s/%s'% (5, 4, 17 ), (7, 51, 53)

I'd give a hint..we have to prompt time like this..
2017/5/4 10:23:34


oh ok i just remembered that i'll try that and get back to you


OK i am sorry but I am completely lost on this last one it says to put them all on line instead of on different lines. This is th first one I have had real trouble with


Can you show me your current code that throwing an error?


print '%s/%s/%s''%s:%s:%s'% (5, 4, 17 7, 51, 53)


oooooohhhhhhhh!!!! I just got it thank you so much I was reading what you said wrong thanks :+1: :+1: :+1:


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


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