I Do The Code And The Code Not Working For Me , Please Help !

+1 Roy Berenshteyn · November 16, 2015
Hi ! 
i Do This Code : 

import os

def get_ip_address(url):
command = ''host'' + url
process = os.popen(command)
results = str(process.read())
marker = results.find('has address') +12
return results[marker:].splitlines()[0]


And The Code Is Not Working : C:\Users\user\AppData\Local\Programs\Python\Python35-32\python.exe C:/Users/user/Documents/Python/ip.address3.py
  File "C:/Users/user/Documents/Python/ip.address3.py", line 6
    command = ''host'' + url
SyntaxError: invalid syntax

Process finished with exit code 1

Please Send Me Fixed Code Or Help Me !
Thanks Roy . 

i tried from this link : https://www.youtube.com/watch?v=I-KYmQCdzls

Post a Reply


Oldest  Newest  Rating
+1 P T · November 16, 2015
Hi Roy,
I can see the problem here.

The line that creates problem for you is: command = ''host'' + url
It has to be: command = ''host '' + url - you missed a space after host.

0 Roy Berenshteyn · November 17, 2015
Hi Pt ! , I Change My Code to Your Fixed Code , But Its Not Work : 

[evaluate ip.address3.py]
Traceback (most recent call last):
  File "C:\Users\user\Documents\Python\ip.address3.py", line 6, in <module>
    command = ''host'' + url
Syntax Error:     command = ''host'' + url: <string>, line 6, pos 20

Roy B.
0 P T · November 17, 2015
Sorry to hear that.
Let me have another look at it tonight and I will get back to asap.

0 P T · November 17, 2015
Hi Roy,
I have used your code as here above and after I've corrected the host part it works as expected.

Change "host" to "host " and it should work.

Have any of the other code worked, as in whois.py?
  • 1



This section is all about snakes! Just kidding.

Bucky Roberts Administrator