Final
Final python:
import maya.cmds as mc
n=0
m=0
for each in range(30):
CubeOne=mc.polyCube(w=4,h=0.6,d=0.6)
mc.move (2,0,0,CubeOne[0])
mc.rotate (-22.5,0,0, CubeOne[0])
CubeTwo=mc.polyCube(w=4,h=0.6,d=0.6)
mc.move (-2,0,0,CubeTwo[0])
mc.rotate (22.5,0,0,CubeTwo[0])
SphereOne=mc.polySphere()
mc.move (-4.5,0,0,SphereOne[0])
SphereTwo=mc.polySphere()
mc.move (4.5,0,0,SphereTwo[0])
Chain= mc.group(CubeOne, CubeTwo, SphereOne, SphereTwo, n='Chain1')
mc.move(0,each+n,0,Chain)
mc.rotate(0,each+m,0,Chain)
n=n+0.5
m=m+15
mc.select( all=True )
Spiralyo = mc.ls( 'Chain*', sl=True )
print Spiralyo
oddlist= []
for each in range(len(Spiralyo)):
if (each%2==1):
selected = "Chain"+str(each)
print selected
oddlist.append(selected)
shader = mc.shadingNode("blinn",asShader=True, name='YellowBlinn')
mc.setAttr(shader + '.color', 1, 1, 0)
mc.select(oddlist)
mc.hyperShade( a=shader)
mc.select (all=True)
mc.select (oddlist,tgl=True)
evenlist= mc.ls( 'Chain*', sl=True )
print evenlist
shader2= mc.shadingNode("blinn",asShader=True, name='RedBlinn')
mc.setAttr(shader2 + '.color', 1, 0, 0)
mc.select(evenlist)
mc.hyperShade( a=shader2)
How I did it:
For the first segment of the script (red font), I used loop and insert simple meshes like cube and spheres and position them in a way that looks like a single 'chain' of the DNA. I set in a range of 30 to duplicate into 30 chains and move plus rotate for each 'chain'.
The Next Step (Orange and Green front), I'm going to find the word 'Chain*' . "List all selected objects named "group*". To get the odd and even numbers of the Chain, I use each%2==1 and find the word 'Chain' and append the results. After obtaining the odd list, I simply toggle select and the even list will be selected.
For the Material part,
shader = mc.shadingNode("blinn",asShader=True, name='YellowBlinn')
mc.setAttr(shader + '.color', 1, 1, 0)mc.select(oddlist)
mc.hyperShade( a=shader)
I use shadingNode to create the blinn, followed by setting the attributes of .color to the values of R,G,B. Finally I select the list and assign the shader to selected.

