To understand how for loops work internally, you must have a good understanding of iterators in Python. Let us see the syntax for the for loop in python along with an example. Using a for loop in python, we can execute a set of statements on each item of a list, set, dictionary or tuple. There are other loops, too, using which we can iterate over the sequences like list, tuple, set, dictionary, etc., but a for loop makes it much easier as we need not manage any loop variables. In Python, we have a for loop that is used to iterate over a sequence (in the case of the song, the sequence can be the list, tuple, etc., of the music bits stream). Behind the scenes, the loop has enabled the song to be played repeatedly any number of times you want on repeat mode. The repeat button provides this looping functionality by implementing the for loop smartly. So by doing this, you are just looping over your favorite song repeatedly. You will do that by tapping the repeat button in the music player app.
Suppose you want to play your favorite song on repeat mode. This functions more like an iterator method found in other object-oriented programming languages than the for loop in other programming languages.
Iterating over a sequence is done using a for loop in Python(that is either a list, a tuple, a dictionary, a set, or a string).