What am I doing wrong?


#1

Hello, I stuck with "Getting the Current Date and Time" lesson. That's What I get after interpreter...

What am I doing wrong ?


#2

Remove the " from the data and time, it does not want a string but the return value of the date time function.

store = datetime.now()

#3

You put "now" as a string, not just datetime.now. Also, you're supposed to print "now".


#4

Excuse me, I never saw in previous lessons "store" ... I don't know how to use it...


#5

It's a variable you can name it anything you want.


#6

@polarstar60
copy paste the following code and you should be good to go

from datetime import datetime
now=datetime.now()
print now


#7

Datetime is a value, not a string, so because of that it doesn't need the ''. I know it is weird.


#8

from datetime import datetime

now = datetime.now()
print datetime.now()

Copy and paste the code I just posted above it then should work. When it says print the value of "now" the value of "now" is " datetime.now()".


#9


#10

This does it! Thanks, I've been stuck for a good 5-10 minutes... Feel like such an idiot


#11

@polarstar60 The problem in your code in the now variable. You have quotations marks around the value of the variable "now" making it NOT a function. Remove those quotation marks so now actually represents the function, and print the variable "now" instead of "datetime.now()" as that's what the exercise wants. Make sure you understand why what you did was wrong before moving on.

If you still don't understand or need more help then just ask. Good luck and happy coding !:slight_smile:

-- @chipjumper36731


#12

Copy and paste this, it will solve the issue.

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)