Skip to content

Instantly share code, notes, and snippets.

@home-gihub
Created June 24, 2025 06:42
Show Gist options
  • Save home-gihub/a92e66f33d66ea4a78e630c9f5f32451 to your computer and use it in GitHub Desktop.
Save home-gihub/a92e66f33d66ea4a78e630c9f5f32451 to your computer and use it in GitHub Desktop.
Outputs rainbow text
import sys
import colorsys
# lolcat in python, it takes the last argument given and then prints it out in rainbow text
def main(argv):
hue =0.0
str = argv[len(argv)-1]
out=""
for i in range(0,len(str)):
r,g,b=colorsys.hsv_to_rgb(hue,1,1)
out += f"\x1b[38;2;{int(r*255)};{int(g*255)};{int(b*255)}m{str[i]}"
hue+=1/100
if hue > 1.0:
hue = 0.0
out += f"\x1b[0;m"
print(out)
main(sys.argv)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment