I want to append each line in file in python
For example:
File.txt
Is it funny?
Is it dog?
Expected Result
Is it funny? Yes
Is it dog? No
Assume that YES, No is given. I am doing in this way:
with open('File.txt', 'a') as w:
w.write("Yes")
But it appends at the end of file. Not on every line.
Edit 1
with open('File.txt', 'r+') as w:
for line in w:
w.write(line + " Yes ")
This is giving the result
Is it funny?
Is it dog?Is it funny?
Yes Is it dog? Yes
I do not need this.It is adding new line with appended string. I need
Is it funny? Yes
Is it dog? No