Firstly, it is important to distinguish between the subject and the object in a sentence. The subject carries out the action or the verb, whereas the subject recieves, experiences or is the target of the actions of the subject i.e., Sa soeur a appris à Jean à parler espagnol. "Sa soeur" is the subject and "Jean" is an object. The confusion starts when we want to replace the object with an object pronoun. To start we must decide if the object is a direct or indirect object pronoun. Direct meaning no preposition needed after the verb such as à, de, dans etc and indirect meaning that you must include some sort of preposition. For DOP, replace the object using either me, te, le, la, nous, vous, les, depending if it's 1st, 2nd or 3rd person and if it's singular or plural.(similar method to using je, tu, il, elle, on, nous, vous, ils, elles), i.e., Il me voit. For IOP, instead we use me, te, lui, nous, vous, leur. (n.b. les, lui and leur can be used for both masc and fem words), i.e., Je lui téléphone. Adding to the last point, when the indirect object in question is inanimate (it) we use, "y" or "en". "Y" is used for verbs followed by à, en, dans, sur. "En" is only used when the verb is followed by de, i.e., j'en ai besoin! In deciding where to put the pronoun, we must remember the object pronoun comes between the subject and the verb. In the passé composé or any other compound tense, this is between the subject and the conjugated part of avoir or être. Additionally, in a negative sentence, it is between "ne" and the verb. When the verb is in the infinitive, the pronoun goes directly before it too.