Using variables to create component names

I’m trying to use a for loop to change the color state of several label. I’ve tried the following syntax with no success.

value = fpmi.gui.color(238,238,238,255) word = 'label a' for i in range(1, 9): event.source.parent.getComponent(word+i).background = value

any suggestions?

Have you tried something like this?value = fpmi.gui.color(238,238,238,255) word = 'label a' for i in range(1, 9): name = "word%s" %(i) #this should produce 'label a1' as the name of the component event.source.parent.getComponent(name).background = value

I think Bobby’s code should be:value = fpmi.gui.color(238,238,238,255) word = 'label a' for i in range(1, 9): name = "%s%d" %(word, i) #this should produce 'label a1' as the name of the component event.source.parent.getComponent(name).background = value

Haha, so it should Al. Thanks for the typo fix!