In literature, a comedy is a genre that typically has a happy ending, often involving humorous or light-hearted elements, and usually portrays the triumph of characters over adversity or challenges. On the other hand, a tragedy is a genre that typically has a sad or catastrophic ending, often involving serious themes, and usually portrays the downfall or demise of the main characters due to their flaws or external circumstances.