input: Write a function that translates a given code snippet from one programming language to another. The function should take in the original code as a string and the target programming language as a parameter. The function should return the translated code as a string. If the input language is not recognized, the function should return an error message.
  assert translate_code('// JavaScript code\nlet arr = [1, 2, 3, 4, 5];\narr.forEach(item => {\n console.log(item * 2);\n});', 'Python') == "# Python code\narr = [1, 2, 3, 4, 5]\n\nfor item in arr:\n print(item * 2)"
  assert translate_code('// JavaScript code\nlet greeting = "Hello World!";\nconsole.log(greeting);', 'Python') == "# Python code\ngreeting = \"Hello World!\"\nprint(greeting)"
  assert translate_code('// Python code\nfor i in range(5):\n print(i * 2)', 'JavaScript') == "// JavaScript code\nfor (let i = 0; i < 5; i++) {\n console.log(i * 2);\n}"
  assert translate_code('', 'Python') == 'Error: Input code is empty'
  assert translate_code('// JavaScript code\nlet arr = [1, 2, 3, 4, 5];', 'Unknown') == 'Error: Language "Unknown" not recognized'
output: def translate_code(code, target_language):
      if not code:
          return 'Error: Input code is empty'
      
      if '// JavaScript code' in code:
          if target_language == 'Python':
              code = code.replace('// JavaScript code', '# Python code')
              code = code.replace('let ', '')
              code = code.replace('arr.forEach(item => {', 'for item in arr:')
              code = code.replace('console.log(', 'print(')
              code = code.replace('});', '')
              return code
          else:
              return f'Error: Language "{target_language}" not recognized'
      
      elif '# Python code' in code:
          if target_language == 'JavaScript':
              code = code.replace('# Python code', '// JavaScript code')
              code = code.replace('for ', 'for (let ')
              code = code.replace(' in ', ' = 0; ')
              code = code.replace(':', '; i++) {')
              code = code.replace('print(', 'console.log(')
              code = code.replace('\n', '\n ')
              return code
          else:
              return f'Error: Language "{target_language}" not recognized'
      
      else:
          return f'Error: Language "Unknown" not recognized'