day 24 - a joke
This commit is contained in:
20
024/main.py
Normal file
20
024/main.py
Normal file
@ -0,0 +1,20 @@
|
||||
#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)
|
||||
Reference in New Issue
Block a user