Question

learning to code with python I'm stuck getting datetime not defined error. Im on codecademy googled all around and not seeing where my code is wrong...sorry for my newbieness in advance and thanks for your help.

Instructions:
Print the current date in the form of mm/dd/yyyy. 

my code:

import datetime
now = datetime.now()
print now

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


print str(current_month)+"/"+str(current_day)+"/"+str(current_year)
Was it helpful?

Solution 2

It should be

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

OTHER TIPS

change your import to:

from datetime import datetime
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top