Python Program to read data from a file line by line


In this program, you will learn how to read data from a file line by line in Python.


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

Example: How to read data from a file line by line in Python

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

for i in file:
    print(i)

Output:

john

28