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

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

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
commented: thanks +13

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?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.