Account
Categories

tell() Method


Definition:

The tell() method shows the current position of the file pointer in the file.

It tells how far the file has been read.

Syntax:

file_object.tell()

Example:

file = open("file1.txt", "r")

print(file.tell())

file.read(5)

print(file.tell())

file.close()

Output:

Exercise

Create a file and use the tell() method to display the current position of the file pointer.