Posted on 25th July 2024|43 views
Is there a foreach function in python 3?
Posted on 25th July 2024| views
No, there isn't any foreach function in python3, but we can use for loop instead.
Syntax:
for element in iterable
operate(element)
But if you want foreach, then you can define your own foreach function
def foreach(My_function, iterable):
for element in iterable:
function(element)