Hello,

I have this code :

import urllib

import zipfile

import re



totaal = 0

commentaar = []

lus = True

image = urllib.URLopener()

image.retrieve("http://www.pythonchallenge.com/pc/def/channel.zip","channel.zip" )

bestand = "readme.txt"

zf = zipfile.ZipFile('channel.zip')

while lus == True :

    for filename in [ bestand ]:

        try:

            data = zf.read(filename)

        except KeyError:

                print 'ERROR: Did not find %s in zip file' % filename

        else:

                print filename, ':'

                data = repr(data)

                print data

                comments = zf.infolist()

                for test in comments:

                    commentaar.append(test.comment)

                print

        nummer = re.search('\d{2,}', data)

        try:

            bestand = str(nummer.group())+".txt"

            print bestand

        except:

            lus = False 

print commentaar

This should make a word.
But I see a lot of rubbisch.

Can anyone explain me what I done wrong here ?

Roelof

Edited 3 Years Ago by mike_2000_17: Fixed formatting

You are at least forgetting to push (CODE) before pasting code and you dropped 'i' from import.

Edited 3 Years Ago by mike_2000_17: Fixed formatting

I'll do the OP a favor here and repost his code (retrieved via Reply) with appropriate formatting:

import urllib
import zipfile
import re

totaal = 0
commentaar = []
lus = True
image = urllib.URLopener()
image.retrieve("http://www.pythonchallenge.com/pc/def/channel.zip","channel.zip" )
bestand = "readme.txt"
zf = zipfile.ZipFile('channel.zip')

while lus == True :

    for filename in [ bestand ]:

        try:
            data = zf.read(filename)

        except KeyError:
                print 'ERROR: Did not find %s in zip file' % filename
        else:
                print filename, ':'
                data = repr(data)
                print data
                comments = zf.infolist()

                for test in comments:
                    commentaar.append(test.comment)
                print

        nummer = re.search('\d{2,}', data)

        try:
            bestand = str(nummer.group())+".txt"
            print bestand

        except:
            lus = False 

print commentaar
Comments
thanks

Rather than trying to determine what the program is supposed to do by reading the code, could you please do your homework and add a few comments to the code as well as a summary of what the program is supposed to do?

This article has been dead for over six months. Start a new discussion instead.