title: Python 3.8 TypeError: can't concat str to bytes - TypeError: a bytes-like object is required, not 'str'
body: <p>Very new to coding. This was the initial code I was trying to get to run but have found it is incompatible with python 3 because of how it handles strings and bytes.</p>
  <pre><code>def opensocket():
       s = socket.socket()
       s.connect((HOST,PORT))
       s.send(&quot;PASS &quot; + PASS + &quot;\r\n&quot;)
       s.send(&quot;NICK &quot; + IDENT + &quot;\r\n&quot;)
       s.send(&quot;JOIN #&quot; + CHANNEL + &quot;\r\n&quot;)
       return s
  </code></pre>
  <p>I think I need to encode these strings into bytes but all the conversion methods I've tried have given errors. here are some i've tried.</p>
  <pre><code>def opensocket():
       s = socket.socket()
       s.connect((HOST,PORT))
       s.send(b&quot;PASS &quot; + PASS + &quot;\r\n&quot;)
       s.send(b&quot;NICK &quot; + IDENT + &quot;\r\n&quot;)
       s.send(b&quot;JOIN #&quot; + CHANNEL + &quot;\r\n&quot;)
  </code></pre>
  <p>and</p>
  <pre><code>def opensocket():
       s = socket.socket()
       s.connect((HOST,PORT))
       s.send(&quot;PASS &quot; + PASS + &quot;\r\n&quot;.encode())
       s.send(&quot;NICK &quot; + IDENT + &quot;\r\n&quot;.encode())
       s.send(&quot;JOIN #&quot; + CHANNEL + &quot;\r\n&quot;.encode())
       return s
  </code></pre>
  <p>both of these give errors saying the str can't be concatenated into bytes
  any help?</p>
  <p>edit: went through the suggested post but I'm gaining nothing from that. it looks so different and I'm so new to this that I can't even tell where the string was he was trying to convert</p>