3 ms·
Unless you want your line numbers to start at 0, do this instead: import sys for lineno, line in enumerate(sys.stdin, 1): print('{:>6} {}'.form
by riskable 13y ago
Unless you want your line numbers to start at 0, do this instead:
import sys
for lineno, line in enumerate(sys.stdin, 1):
print('{:>6} {}'.format(lineno, line[:-1]))
The second argument to enumerate() is the 'start' (can also be a keyword). So by passing a 1 we start there instead of 0.