John Cleese’s Two Rules of Writing Comedy

First Rule: Get your panic in early. Fear gives you energy, so make sure you have plenty of time to use that energy. (The same rule applies to exams.)

Second Rule: Your thoughts follow your mood. Anxiety produces anxious thoughts; sadness begets sad thoughts; anger, angry thoughts; so aim to be in a relaxed, playful mood when you try to be funny.

Cleese, John. So, Anyway