Surah An-Nur, ayah 29

24:29

لَّيۡسَ عَلَيۡكُمۡ جُنَاحٌ أَن تَدۡخُلُواْ بُيُوتًا غَيۡرَ مَسۡكُونَةٖ فِيهَا مَتَٰعٞ لَّكُمۡۚ وَٱللَّهُ يَعۡلَمُ مَا تُبۡدُونَ وَمَا تَكۡتُمُونَ ٢٩

Llaysa 'alaykum junāhun an tadkhulū buyūtan ghayra maskūnatin fīhā matā'ul lakum wallāhu ya'lamu mā tubdūna wamā taktumūn

There is no blame upon you for entering houses not inhabited in which there is convenience987 for you. And Allāh knows what you reveal and what you conceal.

Footnotes

987 Some benefit such as rest, shelter, commodities, one's personal belongings, etc.