In most programming languages, a newer version supports the previous one’s features and syntax so it is easier for developers to switch to a newer version. However, it is not the case for Python. Python 2 and Python 3 are pretty much different from each other.
Learning which Python version was a bit of a debate in the coding community. I’m not sure about old Python users. They need to maintain old projects which were coded in Python 2. But new learners should choose Python 3.
List of differences between Python 2 and Python 3
Python 2 | Python 3 |
Strings are stored as ASCII by default | Strings are stored as Unicode by default |
print is a statement Example: print “Test” | print is a function Example : print(“Test”) |
Many libraries made for Python 2 don’t support Python 3. Python 2 is legacy. | New libraries made for Python 3 don’t support Python 2. Python 3 is the future. |
xrange() is a sequence object that evaluates lazily | This function is replaced by the normal range() |
You have to use an integer in math, it rounds results to the nearest integer. Example: 7/2 = 3 | This version has better integer support. example: 7/2 = 3.5 |