Follow the octet rule which states that a element wants 8 valance shell electrons. If there are valance shell electron alone then it a lone pair.
hope this helps u!!!!!!
2 5 2
Start with THE NO. OF VALENCE ELECTRON OF AN ATOM  Count how many more electrons are needed to fill the valence shell.  This will be the typical number of bonds.  Subtract the number of electrons in the bonds from the total number in a full valence shell and this is the number of unpaired electrons.                                                                                          example is water. 

Oxygen has 6 valence electrons. Once it uses 2 electrons to form covalent bonds with 2 hydrogen atoms, it has 4 electrons left. Hence, it has 2 lone pairs of electrons.
hope this will help u.