Caution: Translations of Quran and Ḥadīth may lead to possible misapplications and misinterpretations. This site is intended for students of sacred knowledge that are proficient in comprehending classical Arabic and have a strong foundation in Islamic sciences. Also note that religious injunctions rely on several aspects beyond what one may glean through reading individual aḥādīth.
quran:12:33

He said, "My Lord, prison is more to my liking than that to which they invite me. And if You do not avert from me their plan, I might incline toward them and ˹thus˺ be of the ignorant."  

He said, ‘My Lord, prison is dearer to me than that to which they are urging me. And if You do not fend off their wiles from me, then I shall tend, I shall incline, towards them and become of the ignorant, the sinful: this is intended as a supplication, which is why God, exalted be He, then says:
القرآن:١٢:٣٣

قَالَ رَبِّ السِّجْنُ أَحَبُّ إِلَيَّ مِمَّا يَدْعُونَنِي إِلَيْهِ ۖ وَإِلَّا تَصْرِفْ عَنِّي كَيْدَهُنَّ أَصْبُ إِلَيْهِنَّ وَأَكُنْ مِنَ الْجَاهِلِينَ  

{قال رب السجن أحبُ إليّ مما يدعونني إليه وإلا تصرف عني كيدهن أصْبُ} أمل {إليهن وأكن} أصر {من الجاهلين} المذنبين والقصد بذلك الدعاء فلذا قال تعالى.