+ 2

What is iteration in python?

I feel like I have been taught this already but I cannot remember what it is. Can someone explain iteration to me in a simple way?

19th May 2022, 10:53 AM
Sam
11 Antworten
+ 3
Sam for iteration in range(3): print("Repeat") Output Repeat # 1st iteration Repeat # 2nd iteration Repeat # 3rd iteration Review lessons 26.1 & 27.1 of Python Core to refresh your learning
19th May 2022, 11:06 AM
Rik Wittkopp
Rik Wittkopp - avatar
+ 2
Itereation means the same thing in every language. It's to take an object like a list or a tuple (an object that has more than one value) and go through those values. A string can be considered an iterable. Because you can go through and select each induvidual value. An example of string iteration: for letter in "ABC": print(letter) # output A B C
19th May 2022, 11:05 AM
Slick
Slick - avatar
+ 2
Repetition
19th May 2022, 1:02 PM
MULUKEN ADDIS
MULUKEN ADDIS - avatar
+ 2
Iteration means repetition of required statement... for example u want print hi 10 times its very hard to always write print statement instead u can write only one or two statements by which we can print hi 10 times... Iteration can be done by using for, while loop statements
20th May 2022, 6:55 AM
Vudayana Sandhya Rani
+ 1
Manav Roy So while True: print("ABC") ABC is iteration, correct?
19th May 2022, 10:58 AM
Sam
+ 1
The dictionary definition: the repetition of a sequence of computer instructions a specified number of times or until a condition is met
19th May 2022, 11:16 AM
Slick
Slick - avatar
+ 1
Iterations isn't a python terminology, but a mathematical/computational idea. Iteration means do the something thing (processing/computation) for a set of values. To achieve this, they need to be ordered or retrieved in such way all elements of it will be work out only one time. In Python, we have a generic way to iterate, as follows for ELEMENT in COLLECTION: ... do things ... it's valuable to note that Python works over the notion of iterator for iterations. What decides which value will come and its order/sequentiality it's the iterator. some objects outputs values in a different order they are added to the object (e.g. set class). more important in this case is to observe that any object becomes iterable in a statement 'for ... in' if it's defined to it (i.e., a class definition) to dunder __iter__. In short, the object itself can be a iterator if __next__ is applied (coherently) for it. note: iteration != interaction (for non native English speakers)
20th May 2022, 11:57 AM
Daniel Bandeira
Daniel Bandeira - avatar
+ 1
I think iteration is simply looping through string of character, like it for loop, iteration takes place by checking through the parameters
21st May 2022, 7:17 AM
Gabriel Adebunmi
0
When for condition is initialised and the no. Of times the loop is formed is called as iteration
21st May 2022, 8:38 AM
Sayali Hemant Patil