Il studente, il zaino, and a sentence later i studenti: three phrases an Italian ear rejects, with nothing misspelled in any of them. You have learned that masculine nouns take il, which is true, and you have applied it everywhere, which is what a rule is for. The reason nobody flags it is that the meaning arrives intact. The reason it sounds off is easier to feel than to explain: il studente is awkward to say, and that awkwardness is the whole reason lo exists.
Masculine singular is il. In front of a short list of sounds it becomes lo, and the list is not about grammar: it is about what your mouth can do at speed. S followed by another consonant: lo studente, lo sport, lo spagnolo, lo sciopero. Z: lo zaino, lo zio, lo zucchero. Gn: lo gnocco. Ps: lo psicologo. Then the rarer ones, pn, x, y and i followed by a vowel: lo yogurt, lo iodio. In front of a plain vowel the article shortens instead: l’amico, l’ufficio, l’orologio.
Then the plurals sort themselves by which singular you used. Il becomes i. Lo and l’ both become gli. So il libro gives i libri, but lo studente gives gli studenti and l’amico gives gli amici. This is why i studenti is the same mistake twice: the singular was lo, so the plural was never going to be i.
Lo studente è arrivato tardi.
Ho dimenticato lo zaino.
Il libro è sul tavolo.
Gli studenti sono in aula.
L’amico di Marco è simpatico.
Notice what the article is reacting to. Not the gender of the noun, which is masculine in all five sentences, and not its meaning. Only the sound it starts with. Il and lo are the same word doing the same job; the choice between them is a question about the next syllable, and it is settled before the noun’s meaning has come into it at all.
Something else follows from that: the article can change when the noun does not. Lo stesso libro, because stesso is now the first word and it begins with st. Il mio zaino, because mio is now first and begins with a plain consonant. The rule looks at whatever word comes immediately after the article, adjective or noun, and nothing else.
The edge that trips people up
The same list governs the indefinite article, which is the part that makes learning it worthwhile. Where lo goes, uno goes: uno studente, uno zaino, uno psicologo, uno sport. Everywhere else it is un: un libro, un tavolo, un ragazzo. And un is also what you use in front of a vowel, with no apostrophe: un amico, un ufficio, un orologio. One list, three articles (lo, gli and uno), all keyed to the same sounds.
Ho un amico che è uno psicologo e un’amica che fa l’avvocato.
The apostrophe is the trap inside that. It belongs to the feminine: un’amica, un’ora, un’isola. The masculine un takes no apostrophe in front of a vowel, because nothing has been shortened: un is the whole word, while un’ is una with its ending dropped. So un amico and un’amica differ by one mark, and the mark is carrying the gender.
A few smaller points sit at the edges of the list. S takes lo only when a consonant follows it: lo studente and lo sport, but il sole, il sabato, il signore, where the s is followed by a vowel. Sc counts as s plus a consonant, so lo sciopero and lo scherzo. And with pn you will hear both articles: lo pneumatico and il pneumatico are both said, so this is not a word to worry about getting right.
Foreign words join the list by their sound rather than their spelling, which means you can work them out. Lo shampoo, because sh is s plus a consonant. Lo yogurt, because y behaves like i before a vowel. Il weekend and il computer, because both start with an ordinary consonant. Nothing here needs to be looked up if you say the word first.
How to hear it
Say il, then say the word, and pay attention to your mouth. Il libro runs. Il studente stalls, and so does il zaino, because in each case your mouth has to start a compound sound with no vowel in front of it. That stall is the signal. Lo is there to supply the vowel that makes the cluster sayable, so the words that need it are exactly the ones that are hard without it.
The test costs nothing and you can run it mid-sentence. It also generalises, which a memorised list does not: a noun you have never seen before will stall or it will not, and that is your answer.
That is the part to be explicit about, because it changes where you look. The noun is not deciding this. Its first two letters are, and you can see them before you know what the word means, which is why lo and gli and uno can be got right on a word you are hearing for the first time.