-3

I wish to split some representative 64-bits elements of a python list into another python list composed by individual hexadecimals.

Input:

['4d5a900003000000', '04000000ffff0000', ...]

Desired output:

['4', 'd', '5', ..., '0', '4', '0', ...]
Eduardo Andrade
  • 111
  • 1
  • 1
  • 13
  • 3
    You have told us what you want to accomplish. But what have you tried, and just where are you stuck? And what do you want us to tell you? – Rory Daulton Feb 27 '18 at 18:32
  • If you know that a `str` is a sequence, then this question is identical: https://stackoverflow.com/questions/952914/making-a-flat-list-out-of-list-of-lists-in-python – Robᵩ Feb 27 '18 at 18:33

1 Answers1

1

You can use a list comprehension:

s = ['4d5a900003000000', '04000000ffff0000']
new_s = [i for b in s for i in b]

Output:

['4', 'd', '5', 'a', '9', '0', '0', '0', '0', '3', '0', '0', '0', '0', '0', '0', '0', '4', '0', '0', '0', '0', '0', '0', 'f', 'f', 'f', 'f', '0', '0', '0', '0']
Ajax1234
  • 69,937
  • 8
  • 61
  • 102
  • 1
    Do you really want to answer a "question" that does not actually state a question and shows no work from the questioner? – Rory Daulton Feb 27 '18 at 18:34