AdventOfCode2023/scripts/new.py
2023-12-05 23:00:18 +00:00

19 lines
631 B
Python

def create_and_populate_file(file_name, content):
try:
with open(file_name, 'w') as file:
file.write(content)
print(f"File {file_name} created and populated successfully.")
except Exception as e:
print(f"Error: {e}")
def main():
# Define the file names and template content
file_names = ["file1.txt", "file2.txt", "file3.txt"]
template_content = "This is a template file.\nYou can replace this content."
# Create and populate each file
for file_name in file_names:
create_and_populate_file(file_name, template_content)
if __name__ == "__main__":
main()