'Toggle a cell\'s state between live and dead'

def toggle(self, y, x):

    if ((x < 0) or (self.X <= x) or (y < 0) or (self.Y <= y)):
        raise ValueError(('Coordinates    out    of    range    %i,%i' % (y, x)))
    if ((x, y) in self.state):
        del self.state[(x, y)]
        self.scr.addch((y + 1), (x + 1), '    ')
    else:
        self.state[(x, y)] = 1
        if curses.has_colors():
            self.scr.attrset(curses.color_pair(random.randrange(1, 7)))
        self.scr.addch((y + 1), (x + 1), self.char)
        self.scr.attrset(0)
    self.scr.refresh()
