How do I figure out thr number of electron groups in a molecule? I thought it was the number of atoms around the central atom but for some cases it isnt right.

For SnCl2, is it 2 electron groups.
For H2O2, how would I figure that out, since both oxygens are the central atoms, would it be two?

You need to explain what you mean by electron groups. Are you talking about "regions of high electron density"?

I mean how many electron groups to determine the shape of it...VSEPR

Yes, you are talking about regions of high electron density.

2 linear
3 trigonal planar
4 tetrahedral
5 trigonal bipyramid
6 octahedral

To determine the number of electron groups in a molecule, you need to consider the arrangement of both bonding pairs and lone pairs of electrons around the central atom.

For SnCl2, the central atom is tin (Sn). The molecule has two chlorine (Cl) atoms bonded to the central atom, and there are no lone pairs of electrons. In this case, each bond (single bond) and each lone pair of electrons around the central atom counts as one electron group. Therefore, SnCl2 has two electron groups.

For H2O2, both oxygen (O) atoms act as central atoms since they are bonded to each other. Similar to SnCl2, you count each bond and each lone pair as an electron group. In H2O2, each oxygen atom is bonded to the other oxygen atom, so there are two O-O bonds. Additionally, each oxygen atom has two lone pairs of electrons. Hence, in total, there are four electron groups in H2O2.

To summarize, the number of electron groups is determined by counting each bond (single, double, or triple) and each lone pair of electrons around the central atom(s).