Get a "for" object in loop
<p>What I'm trying to do first is to add all the values in a tuple or function, I do no know if I'm doing with the best option but finally I achieve it, well, the second it's that in my example code I would like to get the last value of a for loop, because it was the unique idea I had to make it plus all the values, at this moment this code show me the result of the plus oh the all values in a for loop but how can I get the result?</p>

<p>I mean the last value.</p>

<p>This is my code:</p>

<pre><code>def fun(*args):
    valores = args
    print valores

    if len(valores) &gt;= 3:
        print 'es mayor'
        suma = 0
        for n in valores:
            suma += n 
            print suma
            #at this line it works fine, the problem is when I want to get the las value of the for loop
            print suma[3]


    else:
        print 'es menor'


fun(10,10,10,10)
</code></pre>

<p>Thank you for the orientation.</p>

<p>There is a <code>sum</code> function to sum all the numbers in an iterable.</p>

<pre><code>def fun(*args):
    valores = args
    print valores

    if len(valores) &gt;= 3:
        print 'es mayor'
        suma = sum(valores)
        print suma
        print valores[-1]
    else:
        print 'es menor'

fun(10,10,10,10)
</code></pre>

python