Is there a way to refer two attributes of an object in a list?
<p>I want to know who is the taller athlete (object) in a list of objects. If I want to print it, I tried to write this:</p>

<pre><code>print ("The greater height is",max(x.height for x in athletes_list),"meters.")
</code></pre>

<p>It shows the height of the taller athlete, but I don't know how to get his name by this way, putting all commands in print's body. Is there any way to do this?</p>

<p>I know its possible by creating a for like this:</p>

<pre><code>for i in athletes_list:
    if i.height==max(x.height for x in athletes_list):
        print ("The taller athlete is",i.name,"with",i.height,"meters.")
</code></pre>

<p>Is it possible to get both informations only in print's body?
Sorry for bad english.</p>

<p>Reread your question.  The answer is still yes.  Use the <code>format</code> method of strings:</p>

<pre><code>print("The taller athlete is {0.name} with {0.height} meters.".format(max(athletes_list, key=lambda a: a.height)))
</code></pre>

python