-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
16 lines (14 loc) · 822 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
PLACEHOLDER = "[name]"
with open("./Input/Names/invited_names.txt", "r") as names_file:
names = names_file.readlines()
# print(names)
with open("./Input/Letters/starting_letter.txt") as letter_file:
letter_contents = letter_file.read()
for name in names:
stripped_name = name.strip()
new_letter = letter_contents.replace(PLACEHOLDER, stripped_name)
with open(f"./Output/ReadyToSend/letter_for_{stripped_name}.txt", mode="w") as completed_letter:
completed_letter.write(new_letter)
#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