title: Python Guess Game Server-Client
body: <p>Well here is a python server - client guess game programm.Well here my problem is that all works but the loop doesnt.More specificly i can only put one guess from the user.I just want the user to input values and when he finds the right answer the program will close.Right now i can insert only one value for some reason .</p>
  
  <p>Server:</p>
  
  <pre><code>import socket
  import random
  
  
  s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
  s.bind(("192.168.1.3",9000))
  s.listen(5)
  
  (c,a) = s.accept()
  print ("Received connection from", a)
  
  Hello=c.recv(10000).decode()
  
  print(Hello)
  
  greetings="Greetings!"
  c.send((greetings+"\r\n").encode())
  
  game=c.recv(10000).decode()
  print (game)
  
  ready="Ready For The Guess Game!"
  c.send((ready+"\r\n").encode())
  
  random_number = random.randint(1, 20)
  
  running = 1
  
  while running:
      guess=c.recv(10000).decode()
      guess=int(guess)
      print(guess)
  
      if guess &lt;= random_number - 3:
  
          far_message="Far!"
          c.send((far_message+"\r\n").encode())
  
      if guess &gt;= random_number + 3:
  
          far_message="Far!"
          c.send((far_message+"\r\n").encode())
  
      if guess == random_number - 2 or guess == random_number + 2 or guess == random_number + 1 or guess == random_number - 1:
  
          close_message="close!"
          c.send((close_message+"\r\n").encode())
  
  
      if (guess==random_number):
  
          correct_message="Correct!"
          c.send((correct_message+"\r\n").encode())
          running=0
  
  c.close()
  </code></pre>
  
  <p>And the Client:</p>
  
  <pre><code>import socket
  s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
  s.connect(('192.168.1.3',9000))
  
  Hello="Hello"
  
  s.send((Hello +"\r\n").encode())
  
  greetings=s.recv(10000).decode()
  print(greetings)
  
  game="Guess Game Please"
  s.send((game +"\r\n").encode())
  
  game=s.recv(10000).decode()
  print (game)
  
  
  running=1
  while running:
  
      guess = input("Enter your guess: ")
  
      s.send(guess.encode())
  
      close_message = s.recv(10000).decode()
      print (close_message)
  
      far_message = s.recv(10000).decode()
      print(far_message)
  
      correct_message = s.recv(10000).decode()
  
      print(correct_message)
      running=0
  
  
  
  
  s.close()
  </code></pre>