fileinput.isfirstline() in Python Last Updated : 22 Apr, 2020 Improve Improve Like Article Like Save Share Report With the help of fileinput.isfirstline() method, we can get the boolean value as True if line read from the file is very first line else false by using fileinput.isfirstline() method. Syntax : fileinput.isfirstline() Return : Return True if line read is first line of that file. Example #1 : In this example we can see that by using fileinput.isfirstline() method, we are able to get the boolean value as True if line read is very first line from the input file by using this method. Input File – # import fileinput import fileinput # Using fileinput.isfirstline() method for line in fileinput.input(files ='gfg.txt'): print(fileinput.isfirstline()) Output : Example #2 : Input Files – # import fileinput import fileinput # Using fileinput.isfirstline() method for line in fileinput.input(files =('gfg.txt', 'gfg1.txt')): print(fileinput.isfirstline()) Output : Like Article Suggest improvement Next fileinput.lineno() in Python Share your thoughts in the comments Add Your Comment Please Login to comment... Similar Reads Python: Inplace Editing using FileInput fileinput.filename() in Python fileinput.lineno() in Python fileinput.filelineno() in Python fileinput.input() in Python Important differences between Python 2.x and Python 3.x with examples Python program to build flashcard using class in Python Python | Merge Python key values to list Reading Python File-Like Objects from C | Python Python | Add Logging to a Python Script Like J Jitender_1998 Follow Article Tags : Python fileinput-library Python Practice Tags : python