python random hex color

import random
r = lambda: random.randint(0,255)
print('#%02X%02X%02X' % (r(),r(),r()))

Here is what the above code is Doing:
1. We’re using the lambda keyword to create a function that returns a random integer between 0 and 255.
2. We’re using the % operator to format the output of the lambda function.
3. We’re using the print function to print the output of the lambda function.
4. We’re using the hexadecimal format to print the output of the lambda function.

Here’s an example of the output:

#7F00FF

As you can see, the output is a hexadecimal value.