Random Hex Color Generator

  • Share this:

Code introduction


This function generates a random hexadecimal color code.


Technology Stack : Textual library

Code Type : Function

Code Difficulty : Intermediate


                
                    
def random_color_hex():
    import random
    import textual

    color = textual.Color(random.randint(0, 255), random.randint(0, 255), random.randint(0, 255))
    hex_color = color.hex()
    return hex_color