Beginner Coding with Blocks
Chapter 6
>
Level 5
Objective
Collect and dump all the weeds in the passages using a single loop condition.
The path to the courtyard is full of weeds that need to be taken care of. You can automate this process by using loops and using the else section of if blocks to their fullest. There are five (5) weeds in the first passage and nine (9) weeds in the next 2 passages.
Create a for loop block with variable x from 0 to 2 in increments of 1 , so the blocks inside the loop can encompass all three (3) passages around the courtyard.

Inside the loop, use the move forward block for 10 steps, then insert a if block with an else section by dragging & dropping it from the Control menu.

Check if the x variable is equal (=) to 0 by inserting a comparison block into the if block from the Logic Menu and adding a number block from the Math menu. This will check if the loop is in the first cycle.

There are five (5) weeds in the first passage, the x variable is what checks what cycle the loop is in and it always starts at 0. On the Do slot in the if block insert the place block, insert a number block from the Math menu and set the number to 5. Add a turn right block in order to have your character be facing the next hallway.

Insert another place block on the else slot of the if block, insert a number block inside of it and set the number to 9. Insert a turn right block under it inside the slot, this will allow you to place the weeds you collected after grabbing the correct number of weeds.

Once all the weeds have been collected and disposed of in the containers using the single loop and if block, the level will be complete.