input: Write a function to rewrite the given JavaScript code in Python. The JavaScript code iterates over an array and logs each item multiplied by 2. Return the Python equivalent of the code.
  assert rewrite_code("// JavaScript code\nlet arr = [1, 2, 3, 4, 5];\n\narr.forEach(item => {\n console.log(item * 2);\n});") == "# Python code\narr = [1, 2, 3, 4, 5]\n\nfor item in arr:\n print(item * 2)"
  assert rewrite_code("") == ""
  assert rewrite_code("// JavaScript code\nlet arr = [2, 4, 6, 8, 10];\n\narr.forEach(item => {\n console.log(item * 2);\n});") == "# Python code\narr = [2, 4, 6, 8, 10]\n\nfor item in arr:\n print(item * 2)"
  assert rewrite_code("// JavaScript code\nlet arr = [3, 9, 15, 21, 27];\n\narr.forEach(item => {\n console.log(item / 3);\n});") == "# Python code\narr = [3, 9, 15, 21, 27]\n\nfor item in arr:\n print(item / 3)"
  assert rewrite_code("// JavaScript code\nlet arr = [];\n\narr.forEach(item => {\n console.log(item);\n});") == "# Python code\narr = []\n\nfor item in arr:\n print(item)"
output: def rewrite_code(js_code):
      if not js_code:
          return ""
      arr_line = js_code.split('\n')[1]
      arr = arr_line.split('=')[1].strip().strip(';')
      operation_line = js_code.split('\n')[4]
      operation = operation_line.split('console.log(')[1].split(')')[0]
      return f"# Python code\narr = {arr}\n\nfor item in arr:\n print({operation})"