Hi @Lucky_Agrawal,
Look carefully at how the cost function J looks like:
The regularization term is outside of the summation over i and j which means that it should be added to the J function after you exit from both for-loops (just before you divide J by 2).
In your code, you added a regularization term inside the for-loop. Therefore you add it multiple times and you should add it only once.