Perhaps try to separate the colors into 10 buckets instead of 100, then make a list out of it.

colors = ["#first", "#second", "#third", ..., "#tenth"]

Then, write a simple function to assign the number to the corresponding color.

def pick_color(num):
    if num in range(0, 10):
        return colors[1]
    elif num in range(10, 20):
        return colors[2]

...and so on.

Answer from mysl on Stack Overflow
🌐
Google Sites
sites.google.com › view › paztronomer › blog › basic › python-colors
paztronomer - python colors
We could get some additional sophistication, like use HTML codes and experiment creating your own colors. My take home advice is: start simple, use what is provided, and focus more in your analysis/visualizations. If after a while you're comfortable, do some experimentation! Fun fact: What matplotlib does is to transform a set of 3 or 4 numbers to a color (transforming these numbers to a range between 0 and 1, think of it as a percentage where 1 is 100%) When 3 numbers are used, the result is a color that is a combination of red, blue, and green...
Discussions

Python: Retrieving color codes from a number input by user - Stack Overflow
I am working on a school project where we are supposed to retrieve three color codes (for red, green and blue) from a number between 0-16777215 (because 256x256x256=16777216). I am unable to unders... More on stackoverflow.com
🌐 stackoverflow.com
August 31, 2018
Syntax Highlighting in Discord
Discord uses highlight.js for syntax highlighting, which means it supports a huge number of languages. Full list here. More on reddit.com
🌐 r/Python
1
4
April 8, 2018
How does the "color code" for bot embeds work?

The color parameter is a hexadecimal code converted to decimal. Most programming languages will do this conversion for you if you prefix the hex code with 0x.

More on reddit.com
🌐 r/discordapp
3
1
July 22, 2017
pygame.Color(name) -- the list of 657 names you can use

This is easily acessible via the constant color.THECOLORS

>>> from pprint import pprint
>>> import pygame as pg
>>>
>>> pprint(pg.color.THECOLORS)

In general I do believe you will find these follow the allowable html color conventions:
https://htmlcolorcodes.com/color-names/

More on reddit.com
🌐 r/pygame
2
14
June 25, 2018
🌐
GitHub
gist.github.com › rene-d › 9e584a7dd2935d0f461904b9f2950007
ANSI color codes in Python · GitHub
ANSI color codes in Python. GitHub Gist: instantly share code, notes, and snippets.
🌐
Webucator
webucator.com › home › articles › python › python color constants module
Python Color Constants Module | Webucator
August 24, 2021 - STLE1 colors['thistle2'] = THISTLE2 colors['thistle3'] = THISTLE3 colors['thistle4'] = THISTLE4 colors['tomato1'] = TOMATO1 colors['tomato2'] = TOMATO2 colors['tomato3'] = TOMATO3 colors['tomato4'] = TOMATO4 colors['turquoise'] = TURQUOISE colors['turquoise1'] = TURQUOISE1 colors['turquoise2'] = TURQUOISE2 colors['turquoise3'] = TURQUOISE3 colors['turquoise4'] = TURQUOISE4 colors['turquoiseblue'] = TURQUOISEBLUE colors['violet'] = VIOLET colors['violetred'] = VIOLETRED colors['violetred1'] = VIOLETRED1 colors['violetred2'] = VIOLETRED2 colors['violetred3'] = VIOLETRED3 colors['violetred4'] = V
🌐
Matplotlib
matplotlib.org › stable › tutorials › colors › colors.html
Matplotlib
January 28, 2021 - Matplotlib has support for visualizing information with a wide array of colors and colormaps. These tutorials cover the basics of how these colormaps look, how you can create your own, and how you can customize colormaps for your use case · For even more information see the examples page
Find elsewhere
🌐
GeeksforGeeks
geeksforgeeks.org › python › create-random-hex-color-code-using-python
Create Random Hex Color Code Using Python - GeeksforGeeks
July 23, 2025 - import random # Generating a random number in between 0 and 2^24 color = random.randrange(0, 2**24) # Converting that number from base-10 (decimal) to base-16 (hexadecimal) hex_color = hex(color) std_color = "#" + hex_color[2:] print(std_color) ...
🌐
Matplotlib
matplotlib.org › stable › gallery › color › named_colors.html
List of named colors — Matplotlib 3.11.2 documentation
Go to the end to download the full example code. This plots a list of the named colors supported by Matplotlib.
🌐
HolyPython
holypython.com › home › python visualization tutorial › colors with python
Colors with Python | HolyPython.com
March 27, 2021 - You can divide it to any number of colors up to 256 (or the maximum color number in a colormap). Colors will be generated evenly which can be very handy to quickly take advantage of beautiful builtin colormaps that exist in Python libraries.
🌐
Kaggle
kaggle.com › code › asimislam › python-colors-color-cmap-palette
Python Colors for COLOR, CMAP and PALETTE
Checking your browser before accessing www.kaggle.com · Click here if you are not automatically redirected after 5 seconds
🌐
SchemeColor
schemecolor.com › python-logo-colors.php
Python Logo Color Scheme - Palettes - SchemeColor.com
The Python Logo Colors with Hex & RGB Codes has 5 colors which are Nature Blue (#4B8BBE), Philadelphia (#306998), Kournikova (#FFE873), Bright Sun (#FFD43B) and Storm Dust (#646464).
🌐
Matplotlib
matplotlib.org › 2.0.2 › api › colors_api.html
colors — Matplotlib 2.0.2 documentation
This module includes functions and classes for color specification conversions, and for mapping numbers to colors in a 1-D array of colors called a colormap.
🌐
Python Graph Gallery
python-graph-gallery.com › the python graph gallery › colors › available colors in matplotlib
Available colors in Matplotlib
1 week ago - import matplotlib.pyplot as plt ... plt.subplots(nrows=2, ncols=2, figsize=(10, 10), dpi=200) # Hexadecimal color codes color = "#FF5733" axs[0,0].hist( random_data, bins=30, density=True, color=color ) axs[0,0].set_title(f"color ...
🌐
Stigok
blog.stigok.com › 2019 › 06 › 22 › generate-random-color-codes-python.html
Generating random color codes in Python 3 - blog of stigok
June 24, 2019 - import random def rand_24_bit(): """Returns a random 24-bit integer""" return random.randrange(0, 16**6) def color_dec(): """Alias of rand_24 bit()""" return rand_24_bit() def color_hex(num=rand_24_bit()): """Returns a 24-bit int in hex""" return "x" % num def color_rgb(num=rand_24_bit()): """Returns three 8-bit numbers, one for each channel in RGB""" hx = color_hex(num) barr = bytearray.fromhex(hx) return (barr[0], barr[1], barr[2]) c = color_dec() print("� #%6s rgb%s" % ( c, color_hex(c), color_rgb(c) )) This was a good exercise for maths and formatting in Python.
🌐
PyPI
pypi.org › project › colour
colour
JavaScript is disabled in your browser. Please enable JavaScript to proceed · A required part of this site couldn’t load. This may be due to a browser extension, network issues, or browser settings. Please check your connection, disable any ad blockers, or try using a different browser
🌐
Rhino
developer.rhino3d.com › guides › rhinopython › python-rhinoscriptsyntax-color
Rhino - Colors in Python
December 5, 2018 - Colors in Rhino are represented as zero-based, one-dimensional arrays that contain four values. The first 3 values are the Red, Green and Blue channels. Each channel may contain a value from 0 to 255. The fourth value is the Alpha Channel. This control transparency of the color.
🌐
Color Hex
color-hex.com › color-palette › 5949
Python Color Palette
Python color palette created by serena that consists #a4c330,#b3c330,#c2c330,#c3bd30,#c3b530 colors.
🌐
W3Schools
w3schools.com › colors › colors_rgb.asp
Colors RGB and RGBA
Colors Monochromatic Colors Analogous Colors Complementary Colors Triadic Colors Compound