title: TypeError: a bytes-like object is required, not 'list'
body: <p>I want to encode my list into Bytes. How can I do that ?
  My code</p>
  <pre><code>import socket
  import psutil
  import platform
  import os
  
  
  def my_function():
      system_info = []
      system_info.append(&quot;CPU TIMES: &quot; + str(psutil.cpu_times()))
      system_info.append(&quot;Total CPUs: &quot; + str(psutil.cpu_count()))
      system_info.append(&quot;Total CPU Stats: &quot; + str(psutil.cpu_stats()))
      system_info.append(&quot;CPU Frequency: &quot; + str(psutil.cpu_freq()))
      system_info.append(&quot;Virtual Memory: &quot; + str(psutil.virtual_memory()))
      system_info.append(&quot;Disk Partitions: &quot; + str(psutil.disk_partitions()))
      system_info.append(
          &quot;Machine: &quot; + str(system_info.append(&quot;Disk Partitions: &quot; + str(platform.node()))))
      system_info.append(&quot;Node: &quot; + str(platform.node()))
      system_info.append(&quot;Processor: &quot; + str(platform.processor()))
      return system_info
  
  
  HOST = '127.0.0.1'
  PORT = 65432
  arr = []
  with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
      s.bind((HOST, PORT))
      s.listen()
      conn, addr = s.accept()
      with conn:
          print('Connected by', addr)
          data = my_function()
          print(data)
          [arr.append(bytes(element, 'utf-8')) for element in data] #encoding here but getting error
  conn.sendall(arr)
  
  </code></pre>
  <p>I am trying to use <code>Bytes(array, 'utf-8')</code> to encode the array but to no avail and getting the error that a byte like object is required. How can I convert List to this Byte Like Object</p>