I am trying to write text to a file, but I have other text that I need to include, in addition to the target line. When I iterate over entire lines, it is printed with quotation marks, since quotation marks are needed for other text. How to remove quotes from a string that I insert every loop in?
list=['random', 'stuff', 1]
with open(textfile, 'a') as txtfile:
for item in list:
print("""Need to have stuff before %a and after each loop string"""
%item, file=txtfile)
Conclusion: You need to have material before the "random" and after each line of the loop;
Required Conclusion: You need to have material before random and after each line of the loop
source
share