The Python Oracle

Skip first line with Python stdin?

--------------------------------------------------
Hire the world's top talent on demand or became one of them at Toptal: https://topt.al/25cXVn
and get $2,000 discount on your first invoice
--------------------------------------------------

Music by Eric Matyas
https://www.soundimage.org
Track title: Quirky Dreamscape Looping

--

Chapters
00:00 Skip First Line With Python Stdin?
00:38 Accepted Answer Score 8
00:48 Thank you

--

Full question
https://stackoverflow.com/questions/2256...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#python #io #stdin

#avk47



ACCEPTED ANSWER

Score 8


You can use enumerate to keep track of the line number:

for linenum, line in enumerate(sys.stdin):
    if linenum != 0:
        process line