MCPcopy Index your code
hub / github.com/geekcomputers/Python / write_to_file

Function write_to_file

1 File handle/File handle text/question3.py:14–25  ·  view source on GitHub ↗
(file_name)

Source from the content-addressed store, hash-verified

12
13
14def write_to_file(file_name):
15 if os.path.exists(file_name):
16 print(f"Error: {file_name} already exists.")
17
18 else:
19 with open(file_name, "a") as F:
20 while True:
21 text = input("enter any text")
22 F.write(f"{text}\n")
23
24 if input("do you want to enter more, y/n").lower() == "n":
25 break
26
27
28# step2:

Callers 1

question3.pyFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected