I'm trying to turn a list of numbers in a text file into python list form. For example, I want to make

```
1
2
3
4
5

```

into 

```
[1,2,3,4,5]

```

I found something that almost worked in another post using sed.

```
sed '1s/^/[/;$!s/$/,/;$s/$/]/' file

```

but this didn't remove the new line after every number. How can I modify this sed command to get it to do what I want. Also, an explanation on the components of the sed command would also be appreciated. Thanks