[Python] Indentation error encountered when running python in VS Code

Discussão em 'Python' iniciado por Stack, Maio 17, 2025.

  1. Stack

    Stack Membro Participativo

    import numpy as np
    from doubleml.datasets import make_plr_CCDDHNR2018

    np.random.seed(1234)
    n_rep = 1000
    n_obs = 500
    n_vars = 20
    alpha = 0.5

    data = list()

    for i_rep in range(n_rep):
    (x, y, d) = make_plr_CCDDHNR2018(alpha=alpha, n_obs=n_obs, dim_x=n_vars, return_type='array')
    data.append((x, y, d))


    After running the preceding codes, I get the following error:


    File "<python-input-7>", line 3

    data. append((x, y, d))

    IndentationError: unexpected indent
    ​

    This shouldn't have happened as data.append((x, y, d)) was part of the for loop. I've tried it in my RStudio, which also enables people to run Python files, and it works perfectly. Can someone please explain what the issue could be?

    Continue reading...

Compartilhe esta Página