Iterating over tuple entries in a list

kosh kosh at aesaeion.com
Wed Mar 10 16:25:29 EST 2004


On Wednesday 10 March 2004 02:09 pm, Dirk Zimmermann wrote:
> Hi,
>
> I have the following problem:
>
> I have a list with tuples in it, looking like this:
>
> myList = [(1.1, "file1"), (1.2,"file2), (1.9, "file3")]
>
> (I want to store a number calculated from a file together with the
> file.) Than I want to use functions expecting a list of floats. Is there
> an easy way to slice myList? I know, that:

floats = [number for number,filename in myList]




More information about the Python-list mailing list