input: def fix_syntax_errors(code: str) -> str:
      """ Automatically detect and fix Python syntax errors in the given code snippet.
      >>> fix_syntax_errors("def test ():\n    x = 5\n    y = 3\n    z")
      'def test():\n    x = 5\n    y = 3\n    try:\n        z\n    except NameError:\n        print("NameError: Name \'z\' is not defined")'
      """
output:     try:
          compile(code, '<string>', 'exec')
          return code
      except SyntaxError as e:
          lines = code.split('\n')
          if e.lineno is not None and e.offset is not None:
              line_number = e.lineno - 1
              error_line = lines[line_number]
              if "=" not in error_line:
                  lines[line_number] = f"try:\n    {error_line}\n" + \
                                       "except NameError:\n" + \
                                       f"    print(\"NameError: Name '{error_line.strip()}' is not defined\")"
              else:
                  lines[line_number] = f"try:\n    {error_line}\n" + \
                                       "except SyntaxError:\n" + \
                                       f"    print(\"SyntaxError: Invalid syntax in line '{error_line.strip()}'\")"
          return '\n'.join(lines)