RGB to Hex Color Converter

Published by Matt in

Create a function that converts color in RGB format to Hex format.

Examples

rgb_to_hex("rgb(0, 128, 192)") ➞ "#0080c0"

rgb_to_hex("rgb(45, 255, 192)") ➞ "#2dffc0"

rgb_to_hex("rgb(0, 0, 0)") ➞ "#000000"

Notes

The Hex format should be displayed in lowercase.

Watch a quick demo on how Edabit works.