title: Problem with a Syntax in Python on a port scanner
body: <p>I have a problem with a portscanner that I'm tryin' to code, It gives me an error of Syntax, let me show you the code:</p>
  <pre><code>#!/usr/bin/python3
  
  import socket
  from termcolor import colored
  
  sock=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
  socket.setdefaulttimeout(1)
  
  host=input(&quot;[*] Inserisci l'indirizzo:&quot;)
  
  def portscanner(port):
          if socket.connect_ex((host, port)):
                  print (colored(&quot;[!!]La porta %d è aperta&quot;)% (port), 'red')
          else:
                  print (colored(&quot;[+]La porta %d è chiusa&quot;)% (port), 'green')
  for port in range(1,1000):
                  portscanner(port)
  </code></pre>
  <p>The errors:</p>
  <pre><code>Traceback (most recent call last):
    File &quot;portscanner2.py&quot;, line 17, in &lt;module&gt;
      portscanner(port)
    File &quot;portscanner2.py&quot;, line 12, in portscanner
      if socket.connect_ex((host, port)):
  AttributeError: module 'socket' has no attribute 'connect_ex'
  </code></pre>