Lists: Converting Double to Single

Bjoern Schliessmann usenet-mail-0306.20.chr0n0ss at spamgourmet.com
Mon Feb 26 20:30:48 EST 2007


rshepard at nospam.appl-ecosys.com wrote:

> 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].
> 
>   How do I do this, please?

Easy :)

I'll show you by example:

>>> ham = [[1,2,3],[4,5,6]]
>>> ham
[[1, 2, 3], [4, 5, 6]]
>>> ham[0]
[1, 2, 3]
>>> ham.remove([4,5,6])
>>> ham[0]
[1, 2, 3]
>>> ham
[[1, 2, 3]]
>>> 

HTH&Regards,


Björn

-- 
BOFH excuse #453:

Spider infestation in warm case parts




More information about the Python-list mailing list