Tuesday, June 22, 2010

python challenge: room 2

challenge from room 2



my solution:
import re

infile = open('c:\\python26\\MyProgs\\inputfile.txt' , 'r')
instring = infile.read()
infile.close()

#find all non-word characters ...
p = re.compile('\W|_') 

# ... and remove them from instring, 
# so that only word characters are left in instring
print p.sub('', instring) 



official solution

No comments: