Iterating through a Tuple

Lesson Details:
September 17, 2020

Video Transcription: In this lecture I'm going to show you how to iterate through the items of a tuple using for loop this video is brought to you by Appy Pie’s Academy, so as I have told you earlier also a loop means when we traverse when we visit the items of a list or or a tuple one by one so I'm going to give the comments I trading through all the tuple items using our for loop so we will be studying about loops a lot in one of the sections ahead so I'm going to take a tuple employee underscore record first I am going to give some value suppose item code is nine double zero nine and last name is supposed David and first name is suppose Alan or whichever way it is then I'm going to give the value 100,000 then 100,000 you suppose the salary then I'm going to give the bonus suppose nine thousand point four five okay so imply underscore record is a tuple I want to traverse I want to I trade through the items of this tuple so what I am going to do is if you remember people have used for loop in case of lists also so for fire in employ underscore record then I am going to give this print statement print back so if you remember how does it work first time the value of where is going to be nine double zero nine that is the first item of the tuple and that will be printed 91 0 nine second time the value of where is going to be David that is the second item of the tuple and David will be printed and third time over the value is going to be Alan that is the third item of the the third item of the - perd and similarly next time the value of air will be hundred thousand and last time the value of R is going to be this value bonus nine thousand point four five and that will be subsequently printed right so this is how this loop will be I trading through the items of the two part so I'm going to execute this program and yes as you can see this is the output all these values they have been printed one by one.


loader
Course content