Random Color Generator

  • Share this:

Code introduction


This function generates a random color code in the format #RRGGBB, where R, G, B are hexadecimal numbers.


Technology Stack : os, sys, re, json, time, random

Code Type : Function

Code Difficulty : Intermediate


                
                    
import os
import sys
import re
import json
import time
import random

def random_color():
    return f'#{random.randint(0, 0xFFFFFF):06x}'