I have to write strings with newlines and a specific structure to files in Python. When I do
stringtowrite = "abcd ||
efgh||
iklk"
f = open(save_dir + "/" +count+"_report.txt", "w")
f.write(stringtowrite)
f.close()
I'm getting this error:
SyntaxError: EOL while scanning string literal
How can I write the string as it is to a file without deleting the new lines?