It sounds like you're trying to run it in a Python window. In the script editor, press CTRL+T and click "MEL". Paste the code in the new tab in the script editor, and it will run. Good luck!