title: What is happening to the output of this conversion, and why isn't it what I think it should be?
body: <p>I'm trying to write a short program in Python to convert a string from hex into bytes, and then from bytes into base64. I've got a base string in hexadecimal, and the equivalent of the string in base64. The program looks like this: </p>
  
  <pre><code>import codecs
  
  basecode = "49276d206b696c6c696e6720796f757220627261696e206c696b65206120706f69736f6e6f7573206d757368726f6f6d"
  DesiredResult = "SSdtIGtpbGxpbmcgeW91ciBicmFpbiBsaWtlIGEgcG9pc29ub3VzIG11c2hyb29t"
  e = codecs.decode(basecode, 'hex')
  print(e)
  y = codecs.encode(e, 'base64')
  print(y)
  z = bytes.decode(y, 'utf-8')
  print(z)
  print(DesiredResult)
  
  if y == DesiredResult:
      print("Success!")
  </code></pre>
  
  <p>The output I'm getting from the program is as follows: </p>
  
  <pre><code>b"I'm killing your brain like a poisonous mushroom"
  b'SSdtIGtpbGxpbmcgeW91ciBicmFpbiBsaWtlIGEgcG9pc29ub3VzIG11c2hyb29t\n'
  SSdtIGtpbGxpbmcgeW91ciBicmFpbiBsaWtlIGEgcG9pc29ub3VzIG11c2hyb29t
  
  SSdtIGtpbGxpbmcgeW91ciBicmFpbiBsaWtlIGEgcG9pc29ub3VzIG11c2hyb29t
  </code></pre>
  
  <p>As I'm sure you can imagine, this is frustrating, because it means that while I've come close, I haven't actually done what I set out to do. </p>
  
  <p>So, how can I modify this program to make sure that the output of my conversion is exactly the same as the variable <code>DesiredResult</code>? </p>
  
  <p>I know it has to do with the <code>\n</code> that appears in the conversion, but I don't know how it gets there, and I don't know how to get rid of it. </p>
  
  <p>Any and all suggestions greatly appreciated. </p>