# Number to hex

Canonical: https://www.wiki.jodisand.me/snippets/python/to_hex/


Returns the hexadecimal representation of the given number.

- Use `hex()` to convert a given decimal number into its hexadecimal equivalent.

```py
def to_hex(dec):
  return hex(dec)
```

```py
to_hex(41) # 0x29
to_hex(332) # 0x14c
```


