You can import a text file by calling a simple function in python named
Let’s assume we have a text file IH.txt and we want to import it and read it in our program. Thus I write:
for i in range(6):
text += file.readLine()
The read() function reads the whole file and readLine() function reads only one line from the text file.
The loop has 5 iterations and in each iteration, the next line from the file is appended to
text via concatenation.