This would be an anova type of question.
Anova is meant to deal with research questions in which you have a categorical predictor and a continuous outcome, which is the case in your question.
You probably don't meet the assumptions of ANOVA though, because it is meant to deal with groups that are more or less of the same size.
In your case, it sounds like some "groups" are much larger than others (let's consider people with the same political preference as being members of a group).
In that case, you should go for a non-parametric alternative for anova such as the kruskall-wallis test.
People oftentimes don't even check assumptions, so maybe you are not required to check them for your project. Also, oftentimes the differences between parametric and non-parametric tests are not that large.
however, if you want to do it absolutely correctly, you need to check assumptions etc.
For more information on ANOVA, check for instance this video: