Date and time Issue


#1

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.


#2

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


#3

bibleman, thank you for the function call error.


#4

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


#5

it's fixed. Thank you again.


#6

Ok good! Happy coding! :smiley:


#7

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


#8

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


#9

[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)


#10

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


#11

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


#12

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


#13

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