I am trying to create a list of floats from a text file with this code:
exam_data_file = open('exam_data.txt','r')
exam_data = exam_data_file.readlines()
exam_data1 = []
for line1 in exam_data_file:
line1 = float(line1)
exam_data1.append(line1)
print(exam_data1)
but the output is simply: []
Can someone please help?!
Now I get this error message regardless of the changes I make:
line1 = float(line1)
ValueError: invalid literal for float(): 3.141592654
2.718281828
1.414213562
0.707106781
0.017453293