Python, Artificial Intelligence, Software Development, Data Science, Programming.
in file: print(line.strip()) # Using readline() with open('example.txt', 'r') as file: line = file.readline() while line: print(line.strip()) line = file.readline() The strip() method is used to remove any leading or trailing whitespace from the lines. Reading with the with Statement The with