Lists#
Python lists are used to store a collection of items. They are ordered, changeable, and allow duplicate values. You can create a list by enclosing items in square brackets [], separated by commas. Here’s an example:
fruits = ["apple", "banana", "cherry"]
You can access the items of a list by referring to its index number. The index starts at 0 for the first item, 1 for the second item, and so on. Here’s an example:
print(fruits[1])
This will output banana.
You can also change the value of a specific item by referring to its index number. Here’s an example:
fruits[1] = "kiwi"
This will change the second item of the fruits list to kiwi.
You can add an item to the end of a list using the append() method. Here’s an example:
fruits.append("orange")
This will add orange to the end of the fruits list.
You can remove an item from a list using the remove() method. Here’s an example:
fruits.remove("banana")
This will remove banana from the fruits list.
TODO: Build on the above until we demonstrate by building castle walls around our village using this code:
from demo.gate import disable_gate, make_gate
from mciwb.imports import Item, Vec3, Wall
battlements_profile = [
    [
        Item.STONE,
        Item.OAK_PLANKS,
        [Item.STONE, Item.STONE, Item.STONE],
        Item.STONE,
        Item.STONE,
        Item.STONE,
    ],
    [
        [Item.OAK_PLANKS, Item.AIR, Item.TORCH],
        [Item.STONE, Item.STONE, Item.STONE],
        Item.STONE,
        Item.IRON_BARS,
        Item.STONE,
    ],
    [
        Item.STONE,
        Item.OAK_PLANKS,
        [Item.STONE, Item.STONE, Item.STONE],
        Item.STONE,
        Item.STONE,
        Item.STONE,
    ],
    [
        Item.OAK_PLANKS,
        [Item.OAK_PLANKS, Item.STONE, Item.STONE],
        Item.OAK_PLANKS,
        Item.OAK_PLANKS,
        Item.OAK_PLANKS,
    ],
]
def make_walls():
    w = Wall(profile=battlements_profile)
    # build the castle walls
    w.set_start(Vec3(x=630, y=72, z=-1660))
    w.draw(Vec3(x=644, y=72, z=-1660))
    w.draw(Vec3(x=644, y=72, z=-1637))
    w.draw(Vec3(x=659, y=72, z=-1637))
    w.draw(Vec3(x=659, y=72, z=-1606))
    w.draw(Vec3(x=642, y=72, z=-1606))
    w.draw(Vec3(x=642, y=72, z=-1601))
    w.draw(Vec3(x=609, y=72, z=-1601))
    w.draw(Vec3(x=609, y=72, z=-1636))
    w.draw(Vec3(x=617, y=72, z=-1660))
    w.draw(Vec3(x=620, y=72, z=-1660))
    # disable first to remove monitor on the portcullis lever
    disable_gate()
    # build the gate
    make_gate()