title: how to send an array over socket and then get each item in python
body: <p>Below is my server.py and client.py. So I want to print each item in the array separated by a new line. 
  Server.py:</p>
  
  <pre><code>import socket
  
  listener = socket.socket()
  listener.bind(("",12345))
  listener.listen()
  
  while 1:
      conn = listener.accept()
      sock = conn[0]
  
      encoded_message = sock.recv(2048)
      while len(encoded_message) &gt; 0:
      message += encoded_message.decode() + "\n"
      encoded_message = sock.recv(2048)
  
  print(message)
  
  encoded_message = message.encode()
  sock.send(encoded_message)
  sock.shutdown(1)
  
  sock.close()
  </code></pre>
  
  <p>client.py:</p>
  
  <pre><code>import socket
  
  sock = socket.socket()
  sock.connect(("localhost",12345))
  
  testing_strings = ["A123 45",
                 "L65 78",
                 "E486",
                 "D4 1 0",
                 "E1.0",
                 "S1.0",
                 "S0 2 -945 1689 -950 230 -25 1 -1e-15",
                 "Not a number",
                 "S0 2 -945 1689 -950 230 -25 1 0",
                 "S0 2 -945 1689 -950 230 G 1 1e-15"]
  
  for c in testing_strings:
      encoded_message = c.encode()
      sock.send(encoded_message)
  
  sock.shutdown(1)
  
  encoded_message = sock.recv(2048)
  while len(encoded_message) &gt; 0:
      message += encoded_message.decode()
      encoded_message = sock.recv(2048)
  
  print(message)
  sock.close()
  </code></pre>
  
  <p>But I always get</p>
  
  <pre><code>A123 45L65 78E486D4 1 0
  E1.0
  S1.0
  S0 2 -945 1689 -950 230 -25 1 -1e-15
  Not a number
  S0 2 -945 1689 -950 230 -25 1 0
  S0 2 -945 1689 -950 230 G 1 1e-15
  </code></pre>
  
  <p>It seems like the first three items always go together and the rest works just fine. I want to separate them out and print each line. I would appreciate any help. Thanks.
  Expected output:</p>
  
  <pre><code>A123 45
  L65 78
  E486
  D4 1 0
  E1.0
  S1.0
  S0 2 -945 1689 -950 230 -25 1 -1e-15
  Not a number
  S0 2 -945 1689 -950 230 -25 1 0
  S0 2 -945 1689 -950 230 G 1 1e-15
  </code></pre>