I use the following code segment to read a file in python:
with open (\"data.txt\", \"r\") as myfile:
data=myfile.readlines()
Input fil
I don't feel that anyone addressed the [ ] part of your question. When you read each line into your variable, because there were multiple lines before you replaced the \n with '' you ended up creating a list. If you have a variable of x and print it out just by
x
or print(x)
or str(x)
You will see the entire list with the brackets. If you call each element of the (array of sorts)
x[0] then it omits the brackets. If you use the str() function you will see just the data and not the '' either. str(x[0])