---
title: Python 2 vs Python 3
---
We aren't taking a side in the debate. If you are interested in knowing more about it for academic purposes, perhaps this article comparing Python 2 and Python 3 would intrigue you.
But, we cannot also be ignorant of the fact that there are two major flavors of Python out there. Why shoud you care, you ask? Because code written for one version of Python can result in a syntax error in another version of Python.
The following is a valid `print` statement in Python 2, but does not work on Python 3:
```py
print "Hello World"
```
In Python 3, the same statement throws an error like this:
>>> print "hello"
File "", line 1
print "hello"
^
SyntaxError: Missing parentheses in call to 'print'
In Python 2, “print” is treated as a statement rather than a function. There is no need to wrap the text you want to print in parentheses, although you can if you want.
Python 3 explicitly treats “print” as a function, which means you have to pass the items you need to print to the function in parentheses in the standard way, or you will get a syntax error
Using the `print()` function is 'safe' in both Python 2 and 3:
```python
print("Hello World")
```
Another difference between Python 2 and Python 3 is what data structure they return when you call the `map()` function.
In Python 2, `map()` returns a list:
>>> result = map(int,['10','20','30','40'])
>>> print result
>>> [10,20,30,40]
In Python 3, `map()` returns an iterator:
>>> result = map(int,['10','20','30','40'])
>>> print (result)
>>>