code: def parse_python_version(output):
      
      version_line = output.split("\n", 1)[0]
      version_pattern = re.compile(
          r"""
          ^                   # Beginning of line.
          Python              # Literally "Python".
          \s                  # Space.
          (?P<major>\d+)      # Major = one or more digits.
          \.                  # Dot.
          (?P<minor>\d+)      # Minor = one or more digits.
          (?:                 # Unnamed group for dot-micro.
              \.              # Dot.
              (?P<micro>\d+)  # Micro = one or more digit.
          )?                  # Micro is optional because pypa/pipenv#1893.
          .*                  # Trailing garbage.
          $                   # End of line.
      """,
          re.VERBOSE,
      )
  
      match = version_pattern.match(version_line)
      if not match:
          return None
      return match.groupdict(default="0")
docs: Parse a Python version output returned by `python --version`.
  
      Return a dict with three keys: major, minor, and micro. Each value is a
      string containing a version part.
  
      Note: The micro part would be `'0'` if it's missing from the input string.