I have created an error with my list formatting. I have a value of numbers that the list is referring to from a separate text document. It pulls all of the values correctly, and forms it into a list, however the formatting is very 'off'. If I were to have the numbers 55.34, 7.55, and 48.9 from this text document printed into a list, I get an output of [['55.34'], ['7.55'], ['48.90']]
I want to get rid of these quotes and these brackets around them. The numbers are considered a string, but it is to be converted back to a float later in the program, as I want to add all of these numbers together.
I've tried the list.remove
command, but it doesn't seem to work. This is a simplified version of what I am trying to work with:
with open("history.txt", 'r') as f:
deposList = [line.rstrip('\n') for line in f.readlines()]
deposList = [line.split(',') for line in deposList]
list = deposList
print(list)
History.txt is the text file. The first iteration of the deposList gets ride of all of the \n formatting that separated the lines in the text document. I then created a list with these outputs and printed it for verification. I want the list to look like this: [55.34, 7.55, 48.90]