On Tue, Sep 23, 2014 at 11:40:25AM +0200, jarod...@libero.it wrote: > Hi there!! > > I need to read this file: > > pippo.count : > 10566 ZXDC > 2900 ZYG11A > 7909 ZYG11B > 3584 ZYX > 9614 ZZEF1 > 17704 ZZZ3
> How can extract only the number and the work in array? Thanks for any help There is no need for the nuclear-powered bulldozer of regular expressions just to crack this peanut. with open('pippo.count') as f: for line in f: num, word = line.split() num = int(num) print num, word Or, if you prefer the old-fashioned way: f = open('pippo.count') for line in f: num, word = line.split() num = int(num) print num, word f.close() but the first way with the with-statement is better. -- Steven _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor