0
key = input()

a = list(str(key))
print(a)

Does anyone know how to change that a list to get hex numbers in there? Example:

key = "abc"
>> ["a", "b", "c"]

But instead of those letters hex numbers.

Thanks.

Blogames
  • 3
  • 2
  • I actually was trying with some of it, but i need the whole list to be in hex. – Blogames Jan 31 '22 at 22:23
  • So your question is not how to convert a character to its hex value but how to parse a list? – fuenfundachtzig Jan 31 '22 at 22:24
  • Yeah, exacly, i think. – Blogames Jan 31 '22 at 22:24
  • 3
    The question covers that. You can convert the whole string without converting to a list. BTW, just to be snarky, "a", "b", and "c" ARE hex numbers. That's why you should SHOW us exactly what output you want. – Tim Roberts Jan 31 '22 at 22:31
  • what output do you want **exactly**? "Hex numbers" is ambiguous, you at the very least need to specify the *type* of object. Do you want `int` objects corresponding to the hex value a, b, c? Do you want `str` objects in some other format? Please be *precise* – juanpa.arrivillaga Jan 31 '22 at 22:33

1 Answers1

1

Use ord to get the int representation of a character, and hex to get the hex representation of that int.

>>> [hex(ord(c)) for c in "abc"]
['0x61', '0x62', '0x63']
Samwise
  • 68,105
  • 3
  • 30
  • 44