 Hello, my name is Samprit Patel, Assistant Professor, Department of Computer Science and Engineering, Vajrang Institute of Technology, Sholapur. Today, we are going to learn about one of the collection data types in Python that is LIST. At the end of this video, you will be able to understand different collection types in Python, and you will be able to apply LIST in different applications, including with the regular data types in Python like int, float, string, Boolean, Python does have some collection data types. These collection data types are broadly named as sequence type, set type, mapping types. So sequence types contain LIST and tuples. The set types contain sets, and the mapping type contains dictionary. So today, we will be going through in detail with LIST. So LIST is an order sequence of zero or more reference objects. The lists are mutable, that is, the elements of the list can be added, updated and deleted. For example, the marks of students of five subjects and the information of the employee. Now the information of the employee contains employee ID, employee name, employee department and employee salary. So LIST can contain elements of variable types. It can contain a string, it can contain a number or a float or a Boolean value in a single list. So how to create a list? In LIST, the elements of the list are enclosed in square brackets. So square bracket denotes that the particular data type assigned to the variable should be a list data type. Each element is separated by commas. Now if you are using any string as an element in a list, it should appear in between a single code or a double code. See the example below. List one contains four elements of which physics and chemistry are the string type and 1997 and 2000 are of integer type. Now physics is enclosed in a single code and chemistry is enclosed in a double code. So we will see an example of creating list and display the list. So say list one is equal to in square brackets, we will define some number set 10 and it is separated by commas so 10, 20, 30 and we will print the list using print function. So list one will just run this code. So here in the element, we have all taken an integer values. So this is the output of the list. Now updating the list, there are three ways to update a list. You can directly add an element to the list. You can use append function or using the index number of the list, you can add a new element. Now index number of the list starts with zero, we will see one by one. So we want to add an element to the to this particular list. So we'll say list one is equals to now this is the first type list one plus you want to add an element say we'll add 40. So 40 should be again enclosed in square brackets to define that is it is an element of the list and it is to be added to list one. So now we'll print this again. See what will be the output for this will run this. So 40 is been added to the list. Now we will see append function. So append function you have to call the variable list one dot append and you will say 50. So using append function, the element will be by default added to the end of the list. And now we'll print this so that we can get an output. So list one, now you see all the three outputs creating a list updated the list by adding an element using concatenation operator that is plus operator and this is by append function. Now the third type is we'll add the list using its index value. So list one, so we have to add at index number one is equal to say 15 and we'll print this. Now 15 will be added at the index location one. So see this is the index location one, this is 0, 1, 2, 3 and 4. So these are the three ways you can update a list. Now moving forward, take a minute and write a code for the following statement, write a program to create a list that contains the information of the student and display it. So information will contain its roll number, name, gender, department and marks of five subjects. So take a while and try to code for this particular statement. So this statement can be coded in two ways. So these are the solutions, two different solutions. So first one is you can directly add elements to the list using a variable stood and you can print it. Or if you want to print it separately specifying the data, then you can use this particular print function. Now we'll see this by doing it. So say student is equals to the first one was easy, we'll directly jump to the second one so that you can know how to access the variables of the elements of the list. So this is the roll number, the name will be say ABC, after that separating by comma, gender will be male, again separating by comma, the department will be CSE. Then we have to give the marks of five subjects say 50 comma 52 comma 60 comma 74 and say 55. So the second solution print, now we have to print according to the data that we have to specify. So first we will display roll number. So separating with comma, the string, we will pass the index number. So we know the roll number is at the index location zero, so stood of zero. So again, separating by comma, you'll take a string so slash and we'll give it for the new line and we will display a name of the student comma again stood of one because we know that the location one we have the name of the student after that we have gender comma stood of two that is the location of where the gender element will be stored after that again slash and then we have to display department using comma again we will say stood of so zero one two three at the third location we have department of the student and now we will display the marks of the student. So marks of five subjects will be now you don't need to specify all the index numbers. So we know the marks start from four to the end of that element. So it's just we have forgotten the comma. So this will specify that from index number four to the end of the element take all the elements consider all the elements. So we'll just run this. So see your roll number is 20. Then the name is displayed as ABC after that the gender I guess we are missing something here. Okay, so here it was this miss have okay. So we'll see okay the core is right. So following printout statement is for the given problem statement. Now moving forward there are some functions that are provided in Python to process list. So first function is index that find out finds out the index number of the occurrence of the list. Second one is insert. So at I position you can insert the X element X element. So insert X element in the list in position specified by I copy function is used to copy all the elements into a new list. Now extend function so appends list one to list two. So here it is different in copy function. It copies all the elements from one list to another. But the extend function concatenates to list count function returns number of occurrences of X in the list. So that remove function will help you to remove or delete the element of the list. Similarly pop function will also help you to remove that element of the list but it will remove the ending element of the list. Sort function will sort the elements in an ascending order reverse function will reverse the sequence of the elements of the given list and clear function will delete all the elements of the list. So here are some examples you can try these examples as it is just you have to specify the X and I wherever it is necessary. These are some references that I have used to create this video programming in Python 3 of PSN publications and core Python programming of Dream Tech Press. You can go through these books if you want any help through programming in Python. Thank you.