Date and Time Python interface


#1



https://www.codecademy.com/en/courses/python-beginner-en-zFPOx/0/6?curriculum_id=4f89dab3d788890003000096

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)
SyntaxError: multiple statements found while compiling a single statement

This is compiling just fine on the website so I tried to practice it some more on the python 3.6.1 shell and I keep getting this error.

Replace this line with your code.


#2

Hello @chrisdlopez,
I think you have tried something like this..

Problem : You can't run more than one statement in a shell.
You should do this..

Go to file menu and and It will show you new file when you click that you will get something like this..

Paste your code there and save it with someName.py extension.
To run the file : check in menu and hit run.

Note: python 3.x is different from Python 2.x version,syntax-wise. (here we use Python 2.x)
You need to put braces after print function .. print(something here to print)


#3

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