Gran Finale date and time. STUCK!


#1

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

what is wrong with my code ?


#2

Hi this lesson they aske you to Print the date and time together in the form: mm/dd/yyyy hh:mm:ss.

So your print should be lIke that

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

#3

Hey ! That's exactly what I did but it still says I made a syntaxerror


#4

even my code is showing attribute error.

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


#5

You didn't put a , between now.day and now.year


#6

thanx for the solution.


#7

I do not know what I am doing wrong:

from datetime import datetime
now = datetime.now()
print now.month
print now.day
print now.year
print now.hour
print now.minutes
print now.second
print "%s/%s/%s" % (now.month, now.day, now.year)
print "%s:%s:%s" % (now.hour, now.minutes, now.second)

error: your code looks a bit off


#8

So now the error message reads: did you remember to print the now variable

from datetime import datetime
now = datetime.now()
print now.month
print now.day
print now.year
print now.hour
print now.minute
print now.second
print "%s/%s/%s" % (now.month, now.day, now.year)
print "%s:%s:%s" % (now.hour, now.minute, now.second)

I don't know where to put the now variable


#9

I figure it out and here is what it should look like:

from datetime import datetime
print datetime.now()
now = datetime.now()
print now.month
print now.day
print now.year
print now.hour
print now.minute
print now.second
print "%s/%s/%s" % (now.month, now.day, now.year)
print "%s:%s:%s" % (now.hour, now.minute, now.second)


#10

Thank you wizmarco ! That helped me a lot. I´ve just forgotten to put the coma (,) between now.year and the space in left of now hour.

I´m always getting lost in the details.

Regards,

mmsanches


#11

thanks wizmarco! I enjoyed your help!


#12

Thanks that was helpful


#13

Thank you so much!!!!!!!:stuck_out_tongue_winking_eye:


#14

Someone please help me debug.

I'm getting this error

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

Here's my code,

from datetime import datetime
now = datetime.now()

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

#15

i tried this and it still won't work,how old will i be when i finish it hopefully it will tell me that


#16

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)

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

what's wrong?


#17

sorry I see =)))) I forgot replace - - no / / =)))


#18

You need tom put it in the same line but if you look in the instructions it say:"Print the date and time together in the form: mm/dd/yyyy hh:mm:ss" first like you i put first the hour, minute and second, i was stuck there like for 40 mins until now i figured that you need to put it like this: first the month, day, year and then hour, minute, second. And remember tu put it in the same line, hope i helped you sorry if my english is bad i am from mexico.


#19

like this:
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)


#20

This topic is old and keeps getting revived. Anyone who needs help on this exercise is advised to create a new topic in the same category: #python:python-beginner-en-zFPOx

Thread closed.