Files
python_bootcamp/024/main.py
Tanguy Deleplanque c34b9d4c52 day 24 - a joke
2025-07-16 14:42:48 +02:00

21 lines
901 B
Python

#TODO: Create a letter using starting_letter.txt
#for each name in invited_names.txt
#Replace the [name] placeholder with the actual name.
#Save the letters in the folder "ReadyToSend".
#Hint1: This method will help you: https://www.w3schools.com/python/ref_file_readlines.asp
#Hint2: This method will also help you: https://www.w3schools.com/python/ref_string_replace.asp
#Hint3: THis method will help you: https://www.w3schools.com/python/ref_string_strip.asp
with open("input/names/invited_names.txt") as n:
for name in n.readlines():
name = name.strip()
output_letter = ""
with open("input/letters/starting_letter.txt") as l:
for letter_line in l:
output_letter += letter_line.replace("[name]", name)
with open(f"output/ready_to_send/to_{name}.txt", "w") as final:
final.write(output_letter)