Write "Some (but not all) people are Muggles" using first order logic. The predicates to use are: Person(x) - x is a person. Muggle(x) - x is a muggle.
I wrote the following. Is it correct? If not, where did I go wrong? I have seen other answers to this, but I am specifically interested in understanding if mine is correct, and if not where my error was so I can learn from it.
$$ \exists p.[Person(p) \ \wedge Muggle(p) \ \wedge $$ $$ \forall q \ [Person(q) \wedge \ p \neq q \Rightarrow \neg Muggle(q)] $$ $$]$$
Let's think about a simplified version of the world where there are four people (i.e. $\mathit{Person}(\cdot)$ is true for all of them), of whom two are Muggles and two are not - $$ \mathit{Muggle}(\mathrm{Dudley}), \mathit{Muggle}(\mathrm{Vernon}), \neg\mathit{Muggle}(\mathrm{Harry}), \neg\mathit{Muggle}(\mathrm{Ginny}). $$ This is an example of a world (a "model") where we want your formula to be true. In the same way, we would want it to be false for a world where there are only Muggles, or only non-Muggles.
You have: $$ \exists p.[Person(p) \ \wedge Muggle(p) \ \wedge \forall q. \ [Person(q) \wedge \ p \neq q \Rightarrow \neg Muggle(q)]] $$ Unfortunately, this is not true in the example model. Take $p = \mathrm{Dudley}$. While we have $\mathit{Person}(\mathrm{Dudley})$ and $\mathit{Muggle}(\mathrm{Dudley})$, the rest of the statement fails: if $q = \mathrm{Vernon}$ then we have $\mathit{Person}(\mathrm{Vernon})$, and $\mathrm{Dudley}\neq\mathrm{Vernon}$; but since $\mathit{Muggle}(\mathrm{Vernon})$ does hold, the "for all" subformula fails.
Thinking through some other possible combinations of people who might exist in the world, we can see that your formula holds when there is exactly one Muggle. This even includes the world where there is only one person in total, who is a Muggle - which is a shame because "some but not all people are Muggles" is false in that world. That is, your formula isn't actually requiring any non-Muggles to exist. It's OK if they do ($q = \mathrm{Harry}$ or $q = \mathrm{Ginny}$ are fine in the the subformula) but this isn't precisely what's needed.
A hint for how you could proceed: So far, you have the right way of saying that there is somebody around who is a Muggle, which captures the "some people are Muggles" part of the intention. What remains is to say that "not all people are Muggles", or to put it another way, "some people are not Muggles". If you have an idea for how to express this, try testing it against some possible worlds to see if it is true and false just when you want it to be.