Date and time Issue

I’m trying to run the “Datetime” exercise and I’m getting this error message.

Traceback (most recent call last):
File “python”, line 3, in
TypeError: Required argument ‘year’ (pos 1) not found

Here is what my code look like:

from datetime import datetime

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

I’ve looked other discussion about this and it seems to others it worked but not on mine.

Requesting advice.

You need datetime.now() rather than datetime()

bibleman, thank you for the function call error.

1 Like

Well, if that did not fix your problem repost your code. If that did fix your problem your welcome lol

it’s fixed. Thank you again.

1 Like

Ok good! Happy coding! :smiley:

actually it printed the date and time but I got the message. " Did you remember to print the now variable?"

1 Like

repost code and I will take another look at it. I thought everything else was right when I looked at it last except for that small error

[quote=“webpro22078, post:1, topic:61098”]

Here is the correct one:

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)

1 Like

Well that is exactly what I have so idk what the problem was. Glad you figure it out! Happy coding!

Ok, I’ve encountered some problem before. It could possibly be the cache in my browser.

1 Like

Very true. I have as well had that happen to me before. It can be frustrating lol

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