When you have an error, it’s pretty essential to post the error. Otherwise we are guessing.
But I guess the problem is that you are using cmds.aliasAttr() and that returns more than just the blendshape targets. So you’re trying to connect something wrong in the loop.
I honestly have no idea how to do this in maya.cmds. I use PyMEL to iterate over
pm.PyNode('blendShape1').weight which does only return the indices. But that is derived from a Maya API function.
In Maya.cmds, the only other thing I can think off off-hand is
cmds.blendShape('blendShape1', weight=True, q=1) which will list the VALUE of each weight. But at least you get the correct number of weights. And you could use that in your range iterator to get the correct number, at least.
But depending on corrective shapes, or if you delete a weight, and add another, the index order will get messed up. So this can still fail. Which is why I like the PyMEL version. It returns the proper index of each target and gives you the plug to connect to, directly.
For example, after I deleted some random targets and added new ones, I get this, out of order:
for each in pm.PyNode('blendShape1').weight:
cmds.aliasAttr('blendShape1', q=1) seems to return a list of
[target, weight, target, weight, target, weight], you could also just iterate over every 2nd element in that list, and maybe you’ll get the correct result (I have no idea!):
for each in right_LIST:
So instead, skip every 2nd one. This notation is called “index slicing” in Python.
for each in right_LIST[1::2]:
And lastly (sorry for the huge long reply), you don’t need to use a range to iterate over things in Python. Iterate over them directly when possible.
And you can combine two lists together by using zip(). For example:
for eachLeft, eachRight in zip(left_LIST, right_LIST[1::2]):
cmds.connectAttr("null1." + eachLeft, "blendshape1." + eachRight)