can't you just use "enumerate(chans)" here?

Or if you don't want all channels, do "enumerate(chans[:nbchannel])"