The Python Oracle

Skip first line with Python stdin?

Become part of the top 3% of the developers by applying to Toptal https://topt.al/25cXVn

--

Music by Eric Matyas
https://www.soundimage.org
Track title: Sunrise at the Stream

--

Chapters
00:00 Question
00:53 Accepted answer (Score 7)
01:07 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