import string allowed = set("1>> ") if set(code) != allowed: raise Exception("No no no! Only: \"1