CodeSnips

Reading a file line-by-line in Python

file_path = 'example.txt'

# Open the file in read mode ('r')
with open(file_path, 'r') as file:
    for line in file:
        print(line.strip())