I am writing a Python 3 code where the task is to open about 550 files in a directory, read their contents and append it to a string variable 'all_text' which will be say around millions of line long as a single line.
The inefficient code I was using till now is as follows-
all_text += str(file_content)
But then I read that using 'join()' method is efficient, so I tried the following code-
all_text = ''.join(file_content)
The problem with this code is that this is removing the previously held contents of 'all_text' variable and writing the current file's content only!
How do I get around this problem?
Thanks for your help!