You can download this code by clicking the button below.
This code is now available for download.
This function generates a random hexadecimal color code.
Technology Stack : Python Standard Library
Code Type : Function
Code Difficulty :
import random
def random_color_hex():
"""
Generate a random hexadecimal color code.
"""
return '#' + ''.join([random.choice('0123456789ABCDEF') for _ in range(6)])