Keep getting syntax error


#1


my code:
from datetime import datetime

print datetime
now = datetime.now()
print now
response:

2016-11-30 15:50:12.136212
None

"OOPS...make sure you set now to current date and time"


Replace this line with your code.


#2

print datetime

remove this line


#3

thanks! so much i just assumed since it was there to start it should stay.


#4

the next exercise i tried :
from datetime import datetime
current_year = now.year
current_month = now.month
current_day = now.day

now = " datetime.now() "
print now.year
print now.month
print now.day

and got this response:
Traceback (most recent call last):
File "python", line 7, in
AttributeError: 'str' object has no attribute 'year'


#5

now = " datetime.now() "

what is datetime.now() ? is it a string value?
we use " " for string expression.so

remove " "

and why are you are using these line of code?

current_year = now.year 
current_month = now.month
current_day = now.day

read the instruction and do the following....



and always create a new topic for new problem.


#6

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