Hi. >>> f = open('codes.txt') >>> # valid codes starts with 'abc' or '123' or 'ff5' >>> [valid for valid in f.readlines() if valid.startswith('abc') or valid.startswith('123') or valid.startswith('ff5')]
This is just an example, in my application I don't need to check strings against a huge number of cases. If however it would happen, how to modify startswith in order to make it accept a list instead of a simple string? [valid for valid in f.readlines() if valid.startswith(['abc', '123', 'ff5'])] Thanks _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor