Lists: Converting Double to Single

Leif K-Brooks eurleif at ecritters.biz
Mon Feb 26 20:06:45 EST 2007


rshepard at nospam.appl-ecosys.com wrote:
> So I have lists that look like this: [1, 2, 3, 4, 5]. When I
> concatenate lists, I end up with a list of lists that looks like
> this: [[1, 2, 3. 4, 5]. [6, 7. 8, 9. 10]].

Really?
  >>> [1, 2, 3, 4, 5] + [6, 7, 8, 9, 10]
  [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

> Then, I average the column values so I end up with a single list, but
> with two brackets on each end, for example, [[3.5, 4.5, 5.5, 6.5,
> 7.5]].
> 
> Unfortunately, when I try to use that last list in a NumPy function,
> I'm told that it cannot be broadcast to the correct shape. So, what I
> want to do is strip the extra brackes from each end to leave just
> [3.5, 4.5, 5.5, 6.5, 7.5].

l = l[0]




More information about the Python-list mailing list