The Repeated execution of a set of statements is called iteration in Python. Iteration means taking an object like a list or a tuple (an object that has more than one value) and going through those values.
Simple example code Using Iterations in Python Effectively.
Use of for-in (or for each)
The iterator fetches each component and prints data while looping.
cars = ["BMW", "Audi", "McLaren"] for x in cars: print(x)
The Enumerate is a built-in python function that takes input as an iterator, list, etc, and returns a tuple containing an index and data at that index in the iterator sequence.
cars = ["BMW", "Audi", "McLaren"] for x in enumerate(cars): print (x, x)
0 BMW 1 Audi 2 McLaren
Do comment if you have any doubts or suggestions on this Python basic topic.
Note: IDE: PyCharm 2021.3.3 (Community Edition)
All Python Examples are in Python 3, so Maybe its different from python 2 or upgraded versions.
Degree in Computer Science and Engineer: App Developer and has multiple Programming languages experience. Enthusiasm for technology & like learning technical.