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
Remove the Comma from the middle of your print statement.
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.
Thank you, but why do I have to put comma in the paranthesis not in the print statement? Is there any reason for that?
Because of there you need comma to dissociate things to print.
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
i would say @appylpye answer covers your error very well. No extra characters also means no additional spaces (leading nor trailing)
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.