Beautiful is better than ugly.
Your approach is perfectly fine. This is python, when there are a bajillion ways to do something. (Yours is more beautiful too :)). But if you really want it to be more pythonic and/or make it go faster, you could use a set, as F.J's answer has described.
The second solution just looks really hard to follow and understand.
(PS, dict is a built-in type. Don't override it :p. And string is a module from the standard library.)