3
I am trying to solve the python challege #4 but when I run my possible solution I get an error. My solution is the following:
import urllib, re
pattern = re.compile("and the next nothing is \d")
text = "and the next nothing is 12345"
nothing = int(text[-5:])
check = re.search(pattern, text)
while check: # main loop
url = urllib.urlopen("www.pythonchallenge.com/pc/def/linkedlist.php?nothing={}".format(nothing))
text = url.read()
nothing = int(text[-5:])
check = re.search(pattern, text)
print text
and when I run I get this error:
Traceback (most recent call last):
File "Python_Challenge_4.py", line 12, in
url = urllib.urlopen("www.pythonchallenge.com/pc/def/linkedlist.php?nothing={}".format(nothing))
File "/usr/lib/python2.7/urllib.py", line 87, in urlopen
return opener.open(url)
File "/usr/lib/python2.7/urllib.py", line 208, in open
return getattr(self, name)(url)
File "/usr/lib/python2.7/urllib.py", line 463, in open_file
return self.open_local_file(url)
File "/usr/lib/python2.7/urllib.py", line 477, in open_local_file
raise IOError(e.errno, e.strerror, e.filename)
IOError: [Errno 2] No such file or directory: 'www.pythonchallenge.com/pc/def/linkedlist.php?nothing=12345'
Note: I don’t want a solution to python Challenge 4, I just want to know the cause of that mistake.
tried to put
http
at the beginning of the url ?– drgarcia1986