Hi, now we are studying "For loop". "For loop" is different from "while loop" in that it is based on the collection, a collection. A collection it means that it is based on a finite number of items in it. So, repeat action for each item, in a sequence of items. It means that "for loop" is based on a limited number of items contained in a sequence. One example is here. But before explaining for loop, let me introduce the concept of a "list". This is a list. That list is contained in brackets, right, in brackets. Five items are contained in the brackets. That bracket is called a list. In this case, that list contains five numbers from one to five. So basically, a list is a collection of data and is denoted by brackets, brackets. So this for loop means that for "i" is a index, and "i" take one item at each repetition. For example, one is assigned to "i", and classroom one will be printed. Right. And then "i" takes next number contained in the collection of numbers that are contained in the list. So, classroom one, classroom two, keep printing until all items are used up. So, execute. Now, you see how it is working. Now, in this case, the "shapes" variable is also a list because it contains information within brackets. So, a triangle, a square, a circle, a rectangle, four components. Four items are contained in this list. But at this time, each item is not a number. It is a string. So this shapes list contains four string information, and "j" index or "j" variable is initialized at zero, by zero. And for-loop begins. But in this case, "for i in" it is a kind of syntax you must follow. For loop always begins from "for" and index variable follows. And "in" parameter is always used and then a collection itself or a name of collection. At this time "shapes" is simply a list that contains these four strings information. And for loop always end with a colon. In case of "if" statement and "while" control statement, all end with colon. In Python, the header line always ends with a colon. Then whenever a repeatition goes on, "j" index increase from zero to one, until it repeats and then print. In this case, "f-string" again, is used. But in this case, "f-string" uses double quotation mark, not a single quotation mark. So a certain shape number, but it begins from one. And "i" is printed. What is "i"? The first one is triangle. The triangle value is assigned a to "i", and it is printed here. So, if I execute this for loop, it looks like this one: shape one triangle, shape two square, shape three circle, shape four a rectangle. So, extracting each component from the shape list and we are printing shape indexes. So this is a way of using "for loops". And now let me introduce two built-in functions, "len". Len is the shortened word of length. So "len(shape)". Then what number will be returned? There are four components. So four will be returned. Right? And "range function" returns integers from zero to specified number "minus one". Later, I will explain a little bit more about the use of a range function. But in this case, let me just introduce a case of the range function. Number four, in this case, range function contains number four. It means that four numbers. Will be contained, will be created by range function, but the created number ranges from 0 to 3, "0 ,1, 2, 3", four components. So, starting number always integer returned. The starting number, otherwise it is specified, is zero. Then following number is "0, 1, 2, 3", four components. The last, actually here, four is the last number. But four is not the last number. As I said before, the last number will be the specified by number four minus one. So three. Why? Because actually four counts the number of components. But starting number is zero so "0, 1, 2, 3". Then four is satisfied. So, let me execute this function. As I said before "len" function returns four because shapes list, contains four items in it. And type of range, it is range class. Right? And if type range four actually, you are expecting four numbers from zero till three, but actually no number is created. Simply range function is returned again. Because the starting number is 0. Actually, one component range of function means that four is the ending number, designated ending number. Starting from zero, so minus one is three, four components. But range function is not generating(numbers) whenever that object is created. But if you call that range function or execute the range function, then actually you can get the numbers. So later, I will explain lazy evaluation. Because in this case, there are only four number that will be printed eventually. But what about the range function you are creating so large list of numbers? In that case, creating that list of a numbers immediately after making a range object, you are wasting, in a sense memory. You are simply creating range function, range object. And then when you really use that list of numbers, you are realizing, actualizing that list. So actually, when the range function is used or created, the list of numbers is not created. So, for example, in the case, range(len(shape)) means that the number four is actually inserted in range function. And from the range function, we are taking the number sequentially from zero to three. So "i" will take a number from zero to three sequentially. And shape "i" is printed and shapes, the list object has an index. When we specify an index, we are also using brackets. Within brackets, we are writing down index numbers. So the triangle index is 0. (And then) 1, 2, 3. In Python coding, the starting index number is always zero, not one. So, triangle string index is zero, square string index is one, the circle has index number two and the rectangle has three. So if we execute what happens? This one. The next printing function use "f-string" instead of just a usual print function. So, in this case, similarly, not exactly the same two sentences are (printed) for each case. So, one example is what about we use "4" instant of "len (shapes)"? It works exactly the same. But why we are using len(shapes)? Why? Because sometimes, in case of shapes, we already know there are only four components. But you may have a certain list. And so many items are contained (in that list). In that case, rather than checking, by using len function you simple type len and the name of list object. Then automatically, the len number is used for range function, and each number counting start from zero until the ending number, and it is printed as you see here. One difference when you compare a usual print function that we have studied so far, compare it with "f-string". "f-string" is easier because you're not using comma many times to print a sentence. Right? Because within "f-string", starting from anything within "f-string", all information is treated as a string. So, the shape is actually a string character, and within curly bracket, "i" index is used from zero to three. And shapes[i], we are taking out each item from the "shapes" list. So, "i" is zero. Shape index zero means that it is designated to triangle, the first element of the list. In the following for loop, we are using a string. In this case, as you see here, a string is also a collection of characters, a collection of letters. In a sense, a string itself is a sequence of letters. So, a string can be used as a sequence of letters. So, in this case, we are printing each letter horizontally without empty space. We are adding print with nothing contained in parentheses. It means that we are adding simply one more line and also another "for-loop". "total" number is initialize the by zero, and five numbers are contained in this list. And we are adding, we are calculating some of the items. So, let's execute that cell then. Obviously, we are repeating, but what about in this case, we didn't add empty space. We can obviously add empty space in that case. What happens? So one empty space is inserted, and each letter of a string is called. Right? And printed sequentially, and what if we use the print function here without any information in it, then obviously "80" appears at the end of the previous line. So, in order to avoid this one, and in order to present separately, we are inserting in this case. Then "80" appears in different line. Total is used to here, and total number is returned. So "for-loop" can be used for summation. Also in this case, as you see here, not just "i", any identifier, any identifier can be used as an index in a for-loop. Don't have to be "i" or "j" or "k". You can use simply "number" and use that name as an index or variable catching each item of a list. Before closing this video clip, let me ask you again a review question. For loops are often use for extracting items in the sequences, right? In the sequences with finite items in it. So the answer is True.