That command returns a string of references - it doesn't select anything. You could then use Gmatch to get the references to your object. Or do it the way oglu suggested ¯\_(ツ)_/¯ python has a lot more comprehensive ways to work with lists of things.
in python import maya.cmds as mc # select object or face b = mc.ls(sl=1)[0].split("[")[0] # remember a token for comparison below mc.hyperShade(smn=1) # that will select the shader s = mc.ls(sl=1)[0] # remember the selected shader sg = mc.listConnections(s+".oc", s=0, d=1)[0] # figure out the shading group # select the…