That is not the correct syntax, here is your edited code:
>>> while True:
... try:
... var = raw_input('Enter the code: ')
... exec(var)
... except Exception as e:
... print e
...
Instead of except * as e
, use except Exception as e
, because *
as no value associated with it except in imports. However, I would suggest that you keep your try: ... except: ...
's as little as possible, so remove the raw_input()
from the try, unless you really want to surround that too.