Python Challenge – level 6 solution

Get the file channel.zip by changing the URL to “channel.zip”

import zipfile
import re

myzip = zipfile.ZipFile('channel.zip')
s = myzip.read('readme.txt')
print s

m = re.findall('[0-9]{5}',s)
c = ''
while len(m) <> 0:
    n = str(m[0]) + '.txt'
    s= myzip.read(n)
    info = myzip.getinfo(n)
    c = c + info.comment
    m = re.findall('[0-9]+',s)
    print s
    print m
    
print s
print c
>python pc6.py
...
Next nothing is 46145
['46145']
Collect the comments.
[]
Collect the comments.
****************************************************************
****************************************************************
**                                                            **
**   OO    OO    XX      YYYY    GG    GG  EEEEEE NN      NN  **
**   OO    OO  XXXXXX   YYYYYY   GG   GG   EEEEEE  NN    NN   **
**   OO    OO XXX  XXX YYY   YY  GG GG     EE       NN  NN    **
**   OOOOOOOO XX    XX YY        GGG       EEEEE     NNNN     **
**   OOOOOOOO XX    XX YY        GGG       EEEEE      NN      **
**   OO    OO XXX  XXX YYY   YY  GG GG     EE         NN      **
**   OO    OO  XXXXXX   YYYYYY   GG   GG   EEEEEE     NN      **
**   OO    OO    XX      YYYY    GG    GG  EEEEEE     NN      **
**                                                            **
****************************************************************
 **************************************************************

not hockey but oxygen

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s