In Big Sur 11.6.1, if you attempt to save any code that you have entered either in idle, or more appropriate for Python 3.10, idle3, you get more than the Python code, as the idle header will also get saved to the file, rendering it useless until that header info is removed:

What I recommend that you do is to use idle3 to test the results of various Python 3.10 code, and when it does what you want, select and copy/paste the working code into a proper programmer's editor like Sublime Text 4. This is what I have done for years.
Next week, I will receive my M1 Pro MacBook Pro with Monterey, and I will be installing my Python 3.10 development environment on it.
Also, Barney-15E is correct that if you are launching idle, and not idle3, you are getting Tk/Tcl 8.5.9 which is long deprecated on macOS and may actually break now with Monterey. Python 3.10 includes the current Tk/Tcl bits in its bundle and is not dependent on what Apple has failed to update.
Use the following code to determine the Tk/Tcl version:
#!/usr/bin/env python3
import sys
try:
import Tkinter as tk # Python 2
except ImportError:
import tkinter as tk # Python 3
print("Tcl Version: {}".format(tk.Tcl().eval('info patchlevel')))
print("Tk Version: {}".format(tk.Tk().eval('info patchlevel')))
sys.exit()