Note: as I don't have any working version of pymol at the moment,
I am not able to test the solution properly.
However, an easy way is to first create a selection, and then to color it:
select toBecolored, resi 3-8
color yellow, toBecolored
Regarding the L/H chain part, if they are effectively annotated as L and H, something like the following should work:
select toBeColored, ((i. 10-20 or i. 30-40) and c. L ) or ((i. 5-10+20-30) and c. H)
color yellow, toBeColored
Combining both commands is probably possible as:
color yellow, ((i. 10-20 or i. 30-40) and c. L ) or ((i. 5-10+20-30) and c. H)
Pymol allows synonyms (eg. resi and i. or chain and c.).
The following pages may be also helpful:
And the two following links, if you want to get a bit deeper in proper programming with python for pymol (as they can provide you with inspiration):