Teacher's Guide

Chapter 5 / Level 4: Combining String Lists

Teaching Objective:

  • Student practices working with lists
  • Understands how to sum string lists
  • Understands the dynamic between: collect() , combine() and string lists

Guide

This exercise is somewhat similar to level 2 of this chapter however it has some additional quirks. The premise is the same, which is adding lists together and combining them to create an item however this time around the lists use strings and you must use collect() in order to acquire one of the items.

First, grab the empty jar and make your way to the dark X mark by the well, once there use the collect() function to grab some water.

player.collect("water")

Once collected, store the acquired items in a list named base .

base = ["jar", "water"]

After setting up the list make your way through the map and collect the last four (4) items: “orange” , “apple” , “pear” and "peach” . Once collected, store these items in a list called fruits.

fruits = ["orange", "apple", "pear", "peach"]

Once set up make your way to the light X mark and add the two lists together in list named mixture and use it inside combine function() .

mixture = base + fruits
player.combine(mixture)

Once this is accomplished you will have successfully completed the level.

Map overview and path

Map overview and path

Code Solution

import player

player.move_forward()
player.turn_right()
player.move_forward(3)
player.collect("water")
base = ["jar", "water"]
player.turn_right()
player.move_forward(3)
player.turn_left()
player.move_forward()
player.turn_left()
player.move_forward(2)
player.turn_left()
player.move_forward(7)
player.turn_left()
player.move_forward(3)
player.turn_right()
player.move_forward()
player.turn_right()
player.move_forward(2)
player.turn_right()
player.move_forward(2)
player.turn_left()
player.move_forward()
player.turn_right()
player.move_forward(2)
player.turn_left()
fruits = ["orange", "apple", "pear", "peach"]
mixture = base + fruits
player.combine(mixture)
Chapter 5 / Level 4: Combining String Lists | Teacher's Guide