How to output an index while iterating over an array in python

Posted by BeeBand on Stack Overflow See other posts from Stack Overflow or by BeeBand
Published on 2010-06-06T14:39:27Z Indexed on 2010/06/06 14:42 UTC
Read the original article Hit count: 212

Filed under:

I am iterating over an array in python:

for g in [ games[0:4] ]:
    g.output()

Can I also initialise and increment an index in that for loop and pass it to g.output()?

such that g.output(2) results in:

Game 2 - name: Fruit Splat, text: "Splat fruits!", bitrate: 250000

© Stack Overflow or respective owner

Related posts about python