title: Converting string to raw bytes
body: <p>I wrote a program that works with raw bytes (I don't know if this is the right name!) but the user will input the data as plain strings.</p>
  
  <p>How to convert them?</p>
  
  <p>I've tried wih a method but it returns a string with length 0!</p>
  
  <p>Here's the starting string:</p>
  
  <pre><code>5A05705DC25CA15123C8E4750B80D0A9
  </code></pre>
  
  <p>Here's the result that I need:</p>
  
  <pre><code>\x5A\x05\x70\x5D\xC2\x5C\xA1\x51\x23\xC8\xE4\x75\x0B\x80\xD0\xA9
  </code></pre>
  
  <p>And here's the method I wrote:</p>
  
  <pre><code>def convertStringToByte(string):
      byte_char = "\\x"
      n=2
      result = ""
      bytesList = [string[i:i+n] for i in range(0, len(string), n)]
      for i in range(0, len(bytesList)):
          bytesList[i] = byte_char + bytesList[i]
      return result
  </code></pre>