IDLE interactive interpreter can only handle one task at once, you can't do more.
Save the script to a python file (.py
extension), and run it.
From the command line:
$ cd /script_path
$ python script_name.py
Or if you want to run it in IDLE:
Ctrl+N - Paste the code - Save - Press F5
Hope this helps!