Learning something in haram way
Is something learned, which is at least mubah, in a haram way (in a very un-Islamic school with teachers and students of the opppsite gender, while the prayer time passing away, education with haram money etc.) deemed impermissible or makruh tanzihi?
Wa’alaykum as Salām wa rahmatullāhi wa barakātuhu,
The knowledge which is acquired cannot be deemed impermissible or reprehensible.
However, the manner and environment in which it was acquired could be impermissible due to certain prohibited elements, for example, the intermingling of sexes, not performing Ṣalāh on its prescribed time without a valid reason, providing salaries for teachers from unlawful wealth.
As long as one does not have any direct involvement in such elements, one will not be sinful, though it is always best to consider a change of school and environment.
If a person has already studied with these prohibited elements, then he should sincerely repent.