I want to take a list of words from textfile1.txt and replace the word "example" on textfile2.txt to whatever the text is on line one, line two and so on.. How would I do this?
Text file textfile1.txt
user1
user2
user3
user4
user5
Text file textfile2.txt
url/example
url/example
url/example
url/example
url/example
What I have so far
#!/usr/bin/env python3
import fileinput
with fileinput.FileInput("textfile2.txt", inplace=True ) as file:
for line in file:
print(line.replace("example", "user1"), end='')
My goal:
url/user1
url/user2
url/user3