Python Development Course
Chapter
>
Level

Using Dictionaries
Placing objects using dictionaries

Objective

Harvest all the crops on the field and store them in the storeroom using dictionaries.

There are four (4) crops growing on the field: "corn" , "carrot", "wheat" and "parsnip". Harvest the crops and place them in the storeroom by setting up a dictionary.

Walk through the field and grab all the crops, once you’ve successfully navigated through the field. Count the number of each type of crop and store the crops in a dictionary, for ease of handling and storage.

crops = {} crops["corn"] = number of corn stocks in the field .......

First create a dictionary named crops and add the name of each crop as a string. Set the value of each crop the number of crops you’ve grabbed of that specific type.

Once you’ve grabbed all the crops and placed them inside the dictionary, walk to the X marks and face the crates to place the crops in storage using the place() function, like this: place(crops["corn"]) . Each X mark has a sign informing you of the crop that is stored there. Complete the level by storing the crops in the correct storage crates as marked by the signs.

Code book