Differences Between Python 2 and Python3
This is a generic, practical approach that can help you navigate the ambiguity.
Many Python practitioners reached out to me. Asking about which version of Python they should start. My answer to this question is usually something along the lines. Choose the latest version, and check out the differences later on.
But if you are looking for a job, which one you study first? I would say you need to learn both Python 2.7.x and Python 3.x. Because some companies have the old code written in Python 2.7.x. So you must understand it. Because you will spend most of your programming life reading code more than writing code. And regarding writing new code will be in Python 3.x. So is worthwhile to have a look at the major differences. Between those two most popular versions of Python. To avoid common pitfalls when writing the code for a new project.
History
Python 2
Python 2.0 — October 16, 2000
Python 2.1 — April 17, 2001
Python 2.2 — December 21, 2001
Python 2.3 — July 29, 2003
Python 2.4 — November 30, 2004
Python 2.5 — September 19, 2006
Python 2.6 — October 1, 2008
Python 2.7-July 3, 2010
Python3
Python 3.0 — December 3, 2008
Python 3.1 — June 27, 2009
Python 3.2 — February 20, 2011
Python 3.3 — September 29, 2012
Python 3.4-March 16, 2014
Python 3.5 — September 13, 2015
Python 3.6- October 2016
Python 3.7- June 2018.
Python 3.8- October 2019.
Python 3.9- October 2020.
Differences
Code Examples
Python3
Python2
Conclusion
If you’re a beginner, ask yourself which Python language should start with. if I am in your situation. Almost definitely I go for Python 3. As the most recent version that’s growing in usage, and popularity. And most companies are already starting the switch from Python 2 to Python 3.
So is there any advantage to learning Python 2? If your programming level is intermediate to expert level. And you have in mind doing DevOps tasks like configuration management. You have to know Python 2. Since you’ll be dealing with code that has yet to completely support Python 3.