Junior — Middle
Describe the process of iteration in programming or development.
sobes.tech AI
Answer from AI
Iteration is the process of sequentially traversing elements of a collection or data sequence. In programming, iteration allows executing a specific set of actions for each element.
In Python, iteration is usually implemented using loops, for example, for:
numbers = [1, 2, 3, 4, 5]
for num in numbers:
print(num * 2)
Here, the for loop sequentially takes each element from the list numbers and executes the loop body, multiplying the number by 2 and printing the result.
Iteration can occur over lists, strings, dictionaries, files, and other iterable objects.