Grand Finale Date and Time (what is wrong?)


#1



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)

this is my code, but I am getting this error:  Your printed date and time do not seem to be in the right format: mm/dd/yyyy hh:mm:ss 

what should I do?

and also it is showing the wrong hour. Why is that?


Grand Finale Issue
#2

Remove the Comma from the middle of your print statement. :slight_smile:


#3

Hi, @mehmet7 ,

Your output format needs to match the specifications given in the instructions, with no extra characters, not even a comma.

Your program is running on a server, and it is giving you Coordinated Universal Time. If you run it from a Python interpreter installed on your own computer, you will get local time.


#4

Thank you, but why do I have to put comma in the paranthesis not in the print statement? Is there any reason for that?


#5

Because of there you need comma to dissociate things to print.


#6

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 )

this is what I did but I get n error similar to @mehmet7


#7

i would say @appylpye answer covers your error very well. No extra characters also means no additional spaces (leading nor trailing)


#8

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