Ipython interaction

I want to be able to shit+enter and sent python code to IPython rather than just python. However, cursor doesn’t paste code into ipython correct. For instance this code:

with zipfile.ZipFile(zip_path, 'r') as zip_file:
    # Read train.csv directly from the zip file
    with zip_file.open('train.csv') as train_csv:
        train_df = pd.read_csv(train_csv)
    print("Train data loaded into DataFrame")

Works just fine with the default python-repl, however if I close that, and then open ipython in the embedded terminal, when I try shift+enter it to ipython, ipython gets that last print statement indented further and throws an error:

In [7]: with zipfile.ZipFile(zip_path, 'r') as zip_file:
   ...:         # Read train.csv directly from the zip fil
   ...: e
   ...:             with zip_file.open('train.csv') as tra
   ...: in_csv:
   ...:                         train_df = pd.read_csv(tra
   ...: in_csv)
   ...:                             print("Train data load
   ...: ed into DataFrame")
  Cell In[7], line 5
    print("Train data loaded into DataFrame")
    ^
IndentationError: unexpected indent```