Python Practice › sys Module Programs › Program 4
Check the Python version
Write a Python program that checks it is running on Python 3.10 or newer.
Output
3 supported
Approach
- Compare
sys.version_infowith a tuple.
Solution
import sys print(sys.version_info.major)print("supported" if sys.version_info >= (3, 10) else "please upgrade")Output
3 supported
Learn the concept
New to this topic? Read the lesson, then come back.