Malcolm Greene writes:

> Wondering if there's a standard lib version of something like
> enumerate() that takes a max count value?
> Use case: When you want to enumerate through an iterable, but want to
> limit the number of iterations without introducing if-condition-break
> blocks in code.
> Something like:
>
> for counter, key in enumerate( some_iterable, max_count=10 ):
>     <loop logic here>
>
> Thank you,
> Malcolm

for counter, key in zip(range(10), some_iterable):
    <loop logic here>
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to