@apagliari hi, there is a tutorial that hopefully simplifies some of the concepts you are dealing with, the most important difference between the tutorial and your original post is that the tutorial uses millis as opposed to sleep() to create the delay, the millis example is basically a port of blink without delay which is a c/c+ example in the arduino ide. Even though your problem is now solved it would still be worth while to check out the tutorial @ MicroPython simple GPIO control
EDIT with regard to IDE I tend to lean toward Thonny @ https://thonny.org/