A question about using Python in IPython system, The Jupyter Notebook


Hi everyone, I have a problem which is out of context in here but need to ask anyways.

When I try to execute the Python code in Jupyter Notebook, it doesn' work and gives syntax errors.
For example, the starting code was;

print "Hello World!" in python code here is

print (Hello World!") in Ipython.

So can anybody knows why Python codes and IPython codes are different? and Which one to use?

Thanks in advance.


Nothing to do with IPython

○ → ipython2
Python 2.7.12 (default, Jun 28 2016, 08:31:05) 
IPython 5.0.0 -- An enhanced Interactive Python.
In [1]: print 'hello world'
hello world

○ → ipython3
Python 3.5.2 (default, Jun 28 2016, 08:46:01) 
IPython 5.1.0 -- An enhanced Interactive Python.
In [1]: print 'hello world'
  File "<ipython-input-1-d05d0c8adf1f>", line 1
    print 'hello world'
SyntaxError: Missing parentheses in call to 'print'

You're using two different major versions of python (2/3)
Use python 3 if you don't have reason to use python 2


Well well thanks for the reply, now I see more clearly. I like to use python 3, but they teach python with python 2 in code academy I guess, no? Maybe that is the reason of my confusion.


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