# Program to check old and new version numbering are correct or not in Python

PythonServer Side ProgrammingProgramming

#### Beyond Basic Programming - Intermediate Python

Most Popular

36 Lectures 3 hours

#### Practical Machine Learning using Python

Best Seller

91 Lectures 23.5 hours

#### Practical Data Science using Python

22 Lectures 6 hours

Suppose we have a strings older and another string newer. These two are representing software package versions in the format "major.minor.patch", we have to check whether the newer version is actually newer than the older one.

So, if the input is like older = "7.2.2", newer = "7.3.1", then the output will be True

To solve this, we will follow these steps −

• older := a list of major, minor, patch code of older
• newer:= a list of major, minor, patch code of newer
• for i in range the size of list older, do
• := older[i], n := newer[i]
• if n > o, then
• return True
• otherwise when n < o, then
• return False
• return False

Let us see the following implementation to get better understanding −

## Example

Live Demo

class Solution:
def solve(self, older, newer):
older = older.split('.')
for o, n in zip(older, newer):
if int(n)>int(o):
return True
elif int(n)<int(o):
return False
return False
ob = Solution()
older = "7.2.2"
print(ob.solve(older, newer))
"7.2.2", "7.3.1"
True