Beginner Coding with Blocks
Chapter
>
Level

Advanced Lists and Data Structures
Accessing Nested Lists

Objective

Plant seeds in the field by using nested lists.

Seeds need to be planted in the field in order for crops to grow, there are 4 distinct types of crops to be planted: "Pumpkin", "Eggplant", "Tomato" and "Melon". You are in possession of these seeds which are stored in a nested list structure named seeds, a pre-declared constant.

Walk to the X marks and use the plant block to sow the seeds in the field. The plant block takes two inputs: the seeds variable (which contains the nested list data) and a text block with the name of the crop as the key.

For example: use the plant block with seeds variable and "Pumpkin" as the key. This will plant the seeds for Pumpkins. The code will display the number of seeds over the character's head and reveal the number of seeds in the nested list structure.

Water the crops after they are planted using the water block, do this for all four different crops in the field. Afterwards walk to the middle X mark and use the speak block with the seeds variable to call out the number of all seeds that were planted.

Code book