Text Files · 8 / 17 Exercise Easy

Read a text file

Objective

Create a Python program that reads a text file and displays all its lines on the screen. You can use the open() function inside a with block.

Files: the file input.txt already exists. Print each of its lines on the screen, in order.

Output
Lorem ipsum dolor sit amet
consectetur adipiscing elit
sed do eiusmod tempor
incididunt ut labore

Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.

Start exercise