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.
Notes
[987] Some benefit such as rest, shelter, commodities, one's personal belongings, etc.
Verse 29 of Surah An-Nur (24:29), a Medinan surah, is in juz 18, on page 353 of the mushaf. Read it in Arabic with its transliteration, translations and tafsir, and listen to it recited by 72 reciters.
Listen to verse 29 of Surah An-Nur
78 recitations by 72 reciters: pick one and it plays in the player.
All voices (78)
Tafsir of verse 29
Al-Mukhtasar
There is no blame on you, for entering without permission, public houses which are not specifically for any person and which have been prepared for general benefit, such as libraries and shops in markets. Allah knows the actions and conditions which you display and which you hide; none of that is hidden from Him and He shall reward you for them.
There is no blame on you if you enter uninhabited houses with a useful purpose17. And Allah knows what you reveal and what you conceal.
Notes
[17] Such as taking rest, shelter, or one's personal belongings, etc.
There is no sin on you that you enter (without taking permission) houses uninhabited (i.e. not possessed by anybody), (when) you have any interest in them. And Allâh has knowledge of what you reveal and what you conceal.
(It is) no sin for you to enter uninhabited houses wherein is comfort for you. Allah knoweth what ye proclaim and what ye hide.
It is no fault on your part to enter houses not used for living in, which serve some (other) use for you: And Allah has knowledge of what ye reveal and what ye conceal.
It is no sin in you that you enter uninhabited houses wherein you have your necessaries; and Allah knows what you do openly and what you hide.
It is no fault in you that you enter undwelt (Literally: other than being dwelt) houses wherein are belongings for you; and Allah knows whatever you display and whatever you keep back.
There is no blame upon you for seeking bounty from your Lord [during ḥajj]. But when you depart from ʿArafāt, remember Allāh at al-Mashʿar al-Ḥarām. And remember Him, as He has guided you, for indeed, you were before that among those astray.
There is not upon the blind [any] constraint nor upon the lame constraint nor upon the ill constraint nor upon yourselves when you eat from your [own] houses or the houses of your fathers or the houses of your mothers or the houses of your brothers or the houses of your sisters or the houses of your father's brothers or the houses of your father's sisters or the houses of your mother's brothers or the houses of your mother's sisters or [from houses] whose keys you possess or [from the house] of your friend. There is no blame upon you whether you eat together or separately. But when you enter houses, give greetings of peace upon each other - a greeting from Allāh, blessed and good. Thus does Allāh make clear to you the verses [of ordinance] that you may understand.