+ 2
Why should we use for each loop in python
2 ответов
+ 3
It is termed as for loop in python, not for each loop. But it is similar to for loop in other languages. According to it's syntax it sounds more meaningful when called for each.
Example:-
for i in func() :
This sounds more meaningful as for each i in func().
+ 6
There is no foreach loop in Python.
By default the for loop behaves likes a foreach loop.
It is just that Python also created a handy range() object that lets you sequentially generate numbers in a linear increment.