I'm trying to print a file in rainbow colors. But however I have a problem, here is my code:
color = [91, 93, 92, 96, 94, 95]
with open(sys.argv[1]) as f:
for i in f.read():
for c in color:
print('\033[{0}m{1}\033[{0};m'
.format(c, i), end='', flush=True)
The question is, I want the output like this: Hello(H in red, e in yellow, etc. ), but I got the output like this:HHHHHeeeeellll...(first H in red, second H in yello, etc.).
I know that because the first for will loop the second for. But how can I solve this?