Date and time,Grand finale,lesson 6 ,python


#1

Hi guys,I am new to all of this. I got stuck on lesson 6 of date and time,called grand finale


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


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


Thanks


from datetime import datetime
now = datetime.now()
year = now.year
month = now.month
hour = now.hour
minute = now.minute
second = now.second
day = now.day

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


#2

Your output is correct; however, it appears the SCT would rather you hadn't created variables, and instead used the object properties directly.

(now.month,now.day,now.year,now.hour,now.minute,now.second)

#3

It doesn't work :frowning:

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

CODE IS NEXT :

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)


#4

Can Anyone help ,please ?


#5

Added while space, leading and trailing spaces might be causing the error.


#6

No,it isn'tthat either. :frowning:


#7

Tested the following and passed...

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

#8

Omg,it needed double quotation "-" not '-'
Thank you so much <3


#10

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