code: def detect_port(port):
      '''Detect if the port is used'''
      socket_test = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
      try:
          socket_test.connect(('127.0.0.1', int(port)))
          socket_test.close()
          return True
      except:
          return Falsf detect_port(port):
      '''Detect if the port is used'''
      socket_test = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
      try:
          socket_test.connect(('127.0.0.1', int(port)))
          socket_test.close()
          return True
      except:
          return False
docs: Detect if the port is used