enumerate(iter, start=0) for item in enumerate(['subject', 'verb', 'object']): ... print(item) (0, 'subject') (1, 'verb') (2, 'object') f = open('data.txt', 'r') for i, line in enumerate(f): if line.strip() == '': print('Blank line at line #%i' % i) functool Links Python Iterator Python Generator Python Lambda Functional Programming Functional Programming HOWTO — Python 3.12.1 documentation