The .txt file has a string like this:

[[1.0,2.0,3.0],[4.0,5.0,6.0],[7.0,8.0,9.0]]9.5

My goal is to separate that final number from the list and then turn each of them into a list of lists and a float respectively. I've managed to seperate them but they are still strings and I can't convert them...
Here's the code I have:

def string\_to\_list(file):

```
for i in os.listdir(path): 
    if i == file:
        openfile = open(path5+'/'+ i, 'r')
        values = openfile.read()
        p = ']]'
        print(values)
        print()
        bef, sep, after= values.partition(p)
        string1 = values.replace(after,'')
        print(string1)
        print()
        print(after)

```

The output is, using the previous exemple:

[[1.0,2.0,3.0],[4.0,5.0,6.0],[7.0,8.0,9.0]]9.5

[[1.0,2.0,3.0],[4.0,5.0,6.0],[7.0,8.0,9.0]]

9.5

But they are all strings yet.
How can I make this work?
Thank you