How do I enumerate() over a list of tuples in Python?
<p>I've got some code like this:</p>

<pre><code>letters = [('a', 'A'), ('b', 'B')]
i = 0
for (lowercase, uppercase) in letters:
    print "Letter #%d is %s/%s" % (i, lowercase, uppercase)
    i += 1
</code></pre>

<p>I've been told that there's an enumerate() function that can take care of the "i" variable for me:</p>

<pre><code>for i, l in enumerate(['a', 'b', 'c']):
    print "%d: %s" % (i, l)
</code></pre>

<p>However, I can't figure out how to combine the two: How do I use enumerate when the list in question is made of tuples? Do i have to do this?</p>

<pre><code>letters = [('a', 'A'), ('b', 'B')]
for i, tuple in enumerate(letters):
    (lowercase, uppercase) = tuple
    print "Letter #%d is %s/%s" % (i, lowercase, uppercase)
</code></pre>

<p>Or is there a more elegant way?</p>
