170. Python Program to Save a Name in a File and Read It Back
Easyopen()
Overview
Your first file program: open a file, write to it, close it, then open it again and read it.
Problem Statement
Read a name. Open a file called name.txt in mode "w", write Name: followed by the name, and close it. Then open name.txt again in mode "r", read the whole file, close it, and print what you read.
Your program runs in the browser, so the file lives only in this tab's memory. Create it with "w" before you read it.
Use input() with no prompt text: the tests type the input for you, and a prompt would end up in your output.
Input
One line: a name. Example:
Sunny
Output
The text read back from the file:
Name: Sunny
The tests try 3 different names.