Script to create groups of specified residues

If you are working with large multi-chain proteins and want to select multiple groups of residues across different chains, you could do it with repeated mouse and keyboard actions in the hierarchy view. However, if you prefer to do it with a script and type in the specified residue ranges, here is a script for demonstration.