This is inspired from lolcat orginally made in ruby. This project is available on pypi as a python package.
Note: Works on linux ,mac, cygwin and presumably on win 10+ cmd lines, outputs plain text if terminal support not found. Also works on Windows Terminal.
pip install lolpython
from lolpython import lol_py
text = "Lorem ipsum..."
lol_py(text)
lolpython --inp-file "rainbow_this_file.txt"
# if want to do interactive
>> lolpython
>>.. lorem ipsum
>>.. hello world
>>.. [ctrl+d]
>> # rainbow version of the input typed so far