Skip to content
Advertisement

Python join three strings from different lines from log file into one line

I need to concatenate three different strings from different lines into one line. My log file looks like this:

JavaScript

Error:

JavaScript

Below is my code, which is writing in different lines:

JavaScript

Any help much appreciated!

Advertisement

Answer

This happens because there are n at the end of the strings, you should write a helper function

JavaScript

Or

JavaScript

If you only want to remove newlines on the right of the strings and not from the middle or left

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement