python - Retrieving a tuple from a collection of tuples based on a contained value -


I have a data structure that is a collection of tuples in this way:

  things = The first and the third elements are unique (123, 1, "Floll"), (154, 33, "Blurge"), (156, 55, "Blogger"))  
Code>

to archive.

What I have to do, it is to reference a third value and get a specific Tupal like this:

  & gt; & Gt; & Gt;  

To check each value, there should be a better method than writing a loop

If things is a list, and you know that the third element is uni, what about the understanding of the list?

  & gt; & Gt; My_thing = [X in X for X] X [2] == "Blurgle"] [0]  

However under the hood, I agree that through all the values Goes and checks them individually. If you do not like it, then about changing the my_things structure is it a dict and using the first or third value as the key?


Comments

Popular posts from this blog

c++ - Linux and clipboard -

Visual Studio 2005: How to speed up builds when a VSMDI is open? -

booting ubuntu from usb using virtualbox -