for_loop#
- ivy.for_loop(iterable, body_fn, vars)[source]#
Loops over an iterable, passing the current iteration along with a tuple of variables into the provided body function.
- Parameters:
iterable (
Iterable
[Any
]) – The iterable to loop over.body_fn (
Callable
) – A function to call each iteration, first taking the iterator value and then a tuple of extra parameters.vars (
Iterable
[Union
[Array
,NativeArray
]]) – Extra parameters to be passed to body_fn.
- Returns:
ret – The loop’s return value (if any).
Example
``` def body_fn(k, args):
print(k+1) return args
lst = [5,6]