"Except for those who repent, believe, and do righteous work." Qatada said: "Except for those who repent," meaning: he returned from his sin; "and believe," in their Lord; "and do righteous work," in that which is between them and Allah. "For those, Allah will replace their evil deeds with good deeds." As for the replacement in the world: it is the obedience of Allah after disobeying Him, and the remembrance of Allah after forgetting Him.
﴿إِلا مَنْ تَابَ وَآمَنَ وَعَمِلَ عملا صَالحا﴾ قَالَ قَتَادَةُ: ﴿إِلا مَنْ تَابَ﴾ أَيْ: رَجَعَ مِنْ ذَنْبِهِ ﴿وَآمَنَ﴾ بربه ﴿وَعمل صَالحا﴾ فِيمَا بَيْنَهُ وَبَيْنَ اللَّهِ ﴿فَأُولَئِكَ يُبدل الله سيئاتهم حَسَنَات﴾ فَأَمَّا التَّبْدِيلُ فِي الدُّنْيَا: فَطَاعَةُ اللَّهِ بَعْدَ عِصْيَانِهِ، وَذِكْرُ اللَّهِ بعد نسيانه