Search code examples
mit-scratch

Scratch - How can I make something like a for loop?


In a traditional programming language, I would do:

for (int i = 0; i == 5; i++) {
     code here
}

If I needed to loop something five times, I could just use the block repeat 5. But if I want to do something like this:

for (int i = 0; i == 5; i++) {
     if (i >= 3) {
      //Repeat piece of code after 3rd loop
     }
     //Repeated 5 times normally
}

How can I achieve something like this?


Solution

  • Something like this, just create variable and put it inside repeat loop:

    enter image description here