how to fix the _getitem__ method
<pre><code>def pnamedtuple(type_name, field_names, mutable=False):
    pass

    class type_name:
        def __init__(self, x, y):
            self.x = x
            self.y = y
            self._fields = ['x','y']
            self._mutable = False

        def get_x(self):
            return self.x

        def get_y(self):
            return self.y

        def __getitem__(self,i):
            if i &gt; 1 or i &lt;0:
                raise IndexError
            if i == 0 or i == 'x':
                return self.get_x():
            if i == 1 or i == 'y':
                return self.get_y():
</code></pre>

<p>the <strong>getitem</strong> method to overload the [] (indexing operator) for this class: an index of 0 returns the value of the first field name in the field_names list; an index of 1 returns the value of the second field name in the field_names list, etc. Also, the index can be a string with the named field. So, for p = Point(1,2) writing p.get_x(), or p[0]), or p['x'] returns a result of 1. Raise an IndexError with an appropriate message if the index is out of bounds int or a string that does not name a field. </p>

<p>I am not sure how to fix the <em>getitme</em> function. below is the bsc.txt</p>

<pre><code>c--&gt;t1 = Triple1(1,2,3)
c--&gt;t2 = Triple2(1,2,3)
c--&gt;t3 = Triple3(1,2,3)
# Test __getitem__ functions
e--&gt;t1[0]--&gt;1
e--&gt;t1[1]--&gt;2
e--&gt;t1[2]--&gt;3
e--&gt;t1['a']--&gt;1
e--&gt;t1['b']--&gt;2
e--&gt;t1['c']--&gt;3
^--&gt;t1[4]--&gt;IndexError
^--&gt;t1['d']--&gt;IndexError
^--&gt;t1[3.2]--&gt;IndexError
</code></pre>

<p>can someone tell how to fix my _getitem _ function to get the output in bsc.txt? many thanks. </p>