import re
pattern = re.compile('^[0-9]+\\.[0-9]+')
version = '1.2.3.4.5.6.7'

def get_version(s):
    m = pattern.search(s)
if m:
    return m.group()
print(get_version(version))
Get sub-string for major version out of full version string