<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def add(self, cards, end=TOP):
 """ Adds the given list of ``Card`` instances to the top of the stack. :arg cards: The cards to add to the ``Stack``. Can be a single ``Card`` instance, or a ``list`` of cards. :arg str end: The end of the ``Stack`` to add the cards to. Can be ``TOP`` ("top") or ``BOTTOM`` ("bottom"). """

        if end is TOP:
            try:
                self.cards += cards
            except:
                self.cards += [cards]
        elif end is BOTTOM:
            try:
                self.cards.extendleft(cards)
            except:
                self.cards.extendleft([cards])