Better yet use enumerate to save looking up the character index:
for i,char in enumerate(string):
print termcolor.colored(char, colors[i%7]) for i,char in enumerate(string):
print termcolor.colored(char, colors[i%7])(3.2)
from itertools import cycle
for colour, character in zip(cycle(colours), string):
print(termcolor.colored(character, colour))
(2.7) from itertools import cycle, izip
for colour, character in izip(cycle(colours, string):
print termcolor.colored(character, colour)EDIT: The only issue is that if the string has a repeated letter it will be the same color.