Search code examples
pythonpython-3.xpython-collections

Build a string with a deque of integer displayed as hexadecimal


I have a deque full of integer and I would like to build a string (or just print it) in hexadecimal format.

I tried

from collections import deque

a = deque([10,11])
my_string = hex(a)

It says that deque can't be interpreted as an integer. I would like something like :

deque([0xA, 0xB])

Solution

  • pault comment's answer :

        >>> deque(map(hex, a))
    deque(['0xa', '0xb'])