title: While loops between servers and clients (Python)
body: <p>I'm making a number guessing game that runs between a server and a client in IDLE. I'm using two while loops, as follows:</p>
  
  <p>Server:</p>
  
  <pre><code>l = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  
  #Generate random number
  integer = random.randrange(1, 10)
  
  l.bind(("127.0.0.1", 4001)) 
  l.listen(5)
  
  while True: 
      (s, ca) = l.accept()
  
       #Send instruction to client
       s.send("What is your guess? ".encode())
  
       #Receive guess from client
       y = s.recv(4096).decode()
  
       #Break out of the loop if the guess was correct
       if int(y) == integer:
          break
  
  s.close()
  </code></pre>
  
  <p>Client:</p>
  
  <pre><code>#User gets 3 guesses
  for x in range(0, int(chances)):
      s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  
      s.connect(("127.0.0.1", 4001))
  
      #Get instruction from server and make a guess
      y = input(s.recv(80).decode())
  
      #Guess a number and send it to the server
      s.send(y.encode())
  
  s.close()   
  </code></pre>
  
  <p>The user should have 3 chances to get the number right. However, the current setup only lets the user guess once for some reason. After this the server's while loop stops sending instructions and so the user cannot make a guess. How do I fix this?</p>