

class LinkedList(object):
    def __init__(self):
        self.first_node = None
        self.last_node = None

    def new_node(self, prev_node=None, data=None, next_node=None):
        return {
            "prev_node": prev_node,
            "data": data,
            "next_node": next_node}

    def append(self, data):
        new_node = self.new_node(self.last_node, data, None)
        if not self.first_node:
            self.first_node = new_node
            self.last_node = new_node
        else:
            self.last_node["next_node"] = new_node
            self.last_node = new_node
        return new_node

    def index(self, index):
        for i, node in enumerate(self.iter()):
            if i == index:
                return node["data"]

    def __iter__(self):
        return self.iter()

    def iter(self):
        current_node = self.first_node
        while current_node:
            yield current_node['data']
            current_node = current_node['next_node']
