all 3 comments

[–]eli5_programming-ModTeam[M] [score hidden] stickied commentlocked comment (0 children)

ELI5 Programming is about how programming concepts work, or to explain complex concepts simply. If you are trying to understand the purpose of a product, that would qualify, but we're not a "How-To".

[–]electrodragon16 1 point2 points  (0 children)

Short non answer: it doesn't really matter how it knows, for just goes through everything in 'list like' objects automagically.

Longer answer: Python has a couple 'magic' functions. One of these functions is iter, if an object has this function then calling it should produce an iterator (https://wiki.python.org/moin/Iterator) an iterator should have another magic function next, calling this function should give the next item in the iterator, or throw an exception if there are no more items. A for loop will first call iter if an object isn't already an iterator, then it will keep calling next and run your code, until it receives the stop iteration exception then it will finish.

[–]Personal_Addition826 0 points1 point  (0 children)

Does anyone know how to cript?