I want to append some text to the end of a specific line in a text file, inside a loop. So far, I have the following:
batch = ['1', '2', '3', '4', '5']
list = ['A', 'B', 'C']
for i in list:
for j in batch:
os.chdir("/" + i + "/folder_" + j + "/")
file = "script.txt"
MD = "TEXT"
with open(file) as templist:
templ = templist.read().splitlines()
for line in templ:
if line.startswith("YELLOW"):
line += str(MD)
I am a newbie at python. Could you please help?
EDIT: I've updated my script after (great) suggestions, but it still does not change my line.