+ 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?
11 Respuestas
+ 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
+ 2
Repetition
+ 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
+ 1
Manav Roy So
while True:
print("ABC")
ABC is iteration, correct?
+ 1
The dictionary definition: the repetition of a sequence of computer instructions a specified number of times or until a condition is met
+ 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)
+ 1
I think iteration is simply looping through string of character, like it for loop, iteration takes place by checking through the parameters
0
When for condition is initialised and the no. Of times the loop is formed is called as iteration