Statement in "except" tag not working in python
<p>I have written the following code to save an album from a website.</p>

<pre><code>import urllib2
import webbrowser
import os
page=1564848
fileno=1
for fileno in range(1,24):
    pages=str(page)
    filenos=str(fileno)
    picture_page = "url-to-the-website"+pages+".jpg"
    page=page+1
    os.chdir("/home/comrider/Album/")
    if not os.path.exists("3"):
        os.makedirs("3")
    os.chdir("/home/user/Album/3")
    try:
        opener1 = urllib2.build_opener()
        page1 = opener1.open(picture_page)
        my_picture = page1.read()
        filename = filenos + picture_page[-4:]
        fileno=fileno+1
        fout = open(filename, "wb")
        fout.write(my_picture)
        fout.close()
    except:
        fileno=fileno-1 #This statement is not working
        pass
</code></pre>

<p>Since there are missing image number i have given a try and except statement and in the except statement I have given a statement to decrement the file no. that was incremented in the try statements. But that code is not working resulting in incomplete downloading of the album. The working platform is linux. Please help. thanks in advance.</p>
