Python Development Course
Chapter
>
Level

Creating Lists
Combining lists

Objective

Place several supplies in lists and combine them together to form a new product.

It would be a good idea to prepare a dressing for the salad you're planning to have for dinner later. There are 4 different types of items in the field, milk, cream, lettuce and radishes, grab all the items and combine them into a mixture to form Radish dressing.

First grab the milk and cream and put the liquids in a list the same manner as in the previous level by adding the quantiries you collect of each. The milk being the white liquid and the cream being the opaque creammy colored liquid.

liquids = [] liquids.append(3) liquids.append(4) # This code creates a list in this fashion: liquids = [3,4]

Once you grab the the liquids and put them in a list grab the vegetables and do the same. There is another way you can put items in a list if you already know the values you’re adding without the need to add them later.

vegetables = [3, 4]

Once you have created both lists, adding them together is easy, like this mixture = liquids + vegetables. Once you have created the mixture head for the X mark, face the blanket laid out on the floor and use the function combine() to mix everything together in a jug , like this player.combine(mixture).

Code book