Text Files · 9 / 17 Exercise Easy

Appending to a text file

Objective

Create a Python program that asks the user for lines until you press Enter.

The lines should be updated at the end of the text file if it exists, but a new file should be created.

Files: read lines with input() until an empty line is entered and add them, one per line, at the end of the file log.txt. If the file does not exist, create it. The program must not print anything.

Input
dapibus
pretium
radar

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

Start exercise