Following rules are to be followed to fill electrons in different energy levels.
i. If n gives the number of orbit or energy levels, then 2n2 gives the maximum number of electrons possible in a given orbit or energy level. Thus K shell can have a maximum of 2 electrons, L shell can have a maximum of 8 electrons and M-shell can have a maximum of 18 electrons.
ii. If it is the outermost orbit, then it should not have more than 8 electrons.
iii. There should be the stepwise filling of electrons in different orbits, i.e. electrons are not accommodated in a given orbit if the earlier orbits or shells are incompletely filled.