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.