Solution:
You can import a text file by calling a simple function in python named
file=open()
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:
file=open('IH.txt','r')
text=""
for i in range(6):
text += file.readLine()
print(text)
file.close()
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.