So I insert the following code:
reader = open("student.txt",'r') #open a file reader
studentList = []
while True:
line = reader.readline()
#note that '' is 2 single quotes, not one double quote
if line == '': #readers return an empty string when there are no lines left to read
break
line = line[:-1] #strip the trailing end of line character
myStudent = Student(line) #create a student from the name
studentList.append(myStudent) #add the student to the list
print studentList
into the AttachCode so that it retains the whitespace (since whitespace matters in python). The attached code looks like this:
any reason why its not preserving either the whitespace or the newlines? Also, if I edit the message (and dont repaste the code) all that gets left is what is seen here. See the reply for what it looks like initially
reader = open("student.txt",'r') #open a file reader
studentList = []
while True:
line = reader.readline()
#note that '' is 2 single quotes, not one double quote
if line == '': #readers return an empty string when there are no lines left to read
break
line = line[:-1] #strip the trailing end of line character
myStudent = Student(line) #create a student from the name
studentList.append(myStudent) #add the student to the list
print studentList
into the AttachCode so that it retains the whitespace (since whitespace matters in python). The attached code looks like this:
any reason why its not preserving either the whitespace or the newlines? Also, if I edit the message (and dont repaste the code) all that gets left is what is seen here. See the reply for what it looks like initially