A list in Python is a group of values that can contain elements of any data type (numbers, strings, dates, or mixed types), created using square brackets syntax. Lists support zero-based indexing where the first element is at index 0, and elements can be accessed using list[index]. Slicing with list[start:end] retrieves elements from start to end-1, while list[start:end:step] allows selecting every nth element. Lists can be modified by adding elements using += or append(), inserting at specific positions with insert(), and deleting elements using del, pop(), or remove(). Nested lists (lists within lists) are also supported, allowing complex data structures.
Deep Dive
Prerequisite Knowledge
- No data available.
Where to go next
- No data available.
Deep Dive
Python for Beginners - Session 5Added:
cool hi there so very good evening and very good morning to you guys and today we are in session number five of Python for beginner course and we are in the chapter name data structures so what we have dealt in the last session is basically a very important topic that's the data types the variables are the data types is very important thing for you to basically start becoming a programmer and believe me those data types like numeric or integer string or text you know and boolean date all of these data types are the same if you take any programming language it is not just for Python if you want to become a scalar developer later if you want to become a JavaScript developer if you want to become any other programming language developer Ruby on Rails you know even a shell script developer these data types remain same okay so similarly there are very very common data structures but which are available across all the programming languages even Java okay so we are going to deal with important objects that is nothing but data structures inside the memory what are these data structures that's what we are going to deal in the today's session but as I have told in the last session probably it was too quick for too too quick for the few of the big eaters so I am going to take it a little slower today actually the plan was to basically cover up all of these topics as per the plan well before but let us do it little slower I am okay fair or will to cover only these two topics as well today okay so let us do that let's see how am i progressing and I'm clear or not and then bases on that let's take a call whether we are doing it right at the right speed or not okay so I know I think from the last session just to brush up as I told you we have dealt with the data types in the last session we have understood how to create a variable in the page and how to read the data from the variable how to print the variable value in different formats so we have seen print by using plus as a separator or operator and we have used with comma as a separator and surprisingly you need not use both you can even use space ok which I did not even you know show you guys in the last session you can basically try it out yourself ok we have also seen how to print something on the screen using format as well right so all of these things we have done in the last session and we have also seen what is a basic class or an object to create and how to run a function or a variable inside an object right and then we have also seen how to prompt inputs and don't worry if prompt inputs is not that clear for you in the last session we are going to use whatever I know in the process of me training the complete curriculum whatever we will be covering in the past sessions I am going to help you reiterate the same thing in the following sessions as you keep going through the sessions you will feel that ok I'll always try to reiterate what happened in the past with what you are learning in the current session ok I try to do that best so that you will recollect it and then you learn it better ok so let's quickly start off with this list of you know the data structures that I have we will start with very very important data structure that will stick to you throughout the life of a Python programming that is list list is also called as array okay in few of the programming languages list is called as an array alright so now let me explain you what is first of all an array or what is first of all a list ok so I have the code ready for you on the screen but I will be typing it you know so that you know you also get to know how to type something what is the difference in typing etcetera so we will do that anyway but I have written everything on the screen just for my reference so that I don't forget covering few topics right as the process of me typing a code on the screen I don't want to miss anything alright so first of all let me define what is a list list is also an another variable actual but the list is group of elements list is nothing but group of values list can be group of numbers Lisp can be group of text or a string variables list can be group of dates lists can be group of both numbers and text anything if you want to group few values into one variable you can't do it in a direct variable you have to either choose one of these data structures it can be list or it can be a dictionary or it can be a couple or it can be a set okay you can create these for different types of data structures inside your memory and it is also a variable but the variable type is not like you have seen in the last session it will not be string it will not be integer it will not be you know a date time it will not be you know boolean instead these types of these variables will be called as only lists okay so as I define the value or either defined the definition of lists what is the list it is just an another variable that you can create inside your Python just say our school underscore list and it is nothing but group of values in it so I can say 10 20 30 40 just like I have here as well but I'm typing it but what is the syntax used observe here carefully anything with the square braces is called that will be that is the syntax to create a list inside your Python variable inside your Python kernel now if I execute this just say command return on the right hand side let's see it is still collecting the data is it like again a problem for me just like in the last time okay all right let me wait for a second just to see if it doesn't fail I think it is always failing because I don't have an R interpreter okay on my system I don't have our interpreter I think that's the reason a lot of times it is hanging out okay because it is not hanging so let me actually go ahead guess this particular control is not hanging for me right so let me assume that it is going fine and then I also have a event log am sorry for this let me delete this event I don't think this is a problem okay I think that is an issue on my console please wait if I have to just kill it it is not killing again the same problem so guys give me one second so I just say oh okay gone so let me find out what is my activity monitor let me find out my PID of this python it is two three one six three let me go to my terminal and then I'll kill it - nine two three one six three so let me come back and check yeah two three one six three killed cool I can see the message here killed right so let me basically reload my Python control so let me run this one now I think I should see yeah exactly okay so now if you see here you're automatically seeing this variable as what the type is list so what is a list list is group of values that's it now a list can be of numeric data type a list can be you can have I am saying list - and I'm again square braces is the one I say hello and then I say or school and then I say right class etc etcetera if I execute this this is an another variable created it is also of type list if you observe carefully in this console I'm also getting some message along with the list for in the sense there are four elements inside this list okay each and every value is termed as element it is called element that's a language that's it I mean that's the way you call it as a Python programmer okay but the second one it has got a list of three elements hello' is one one element or skill is another element class is another element right now you might be wondering can i basically create a list with the combinations of both right there was a space here so with a combination of both number and text right let me copy paste all of this here right can I create this yes absolutely so you have a list of seven elements it is a combination of numbers and as well as you know text or a string there is no problem at all now why do I basically create a list right in the real world you will be you know directly getting you know a bad requirement for sure if you have to develop any Python program for any requirement in the market today even at your work I bet you you won't write a program without creating a list it becomes so important right why will it become so important when we deal with the projects you will come to know or when we go forward with the further topics you will definitely know that I always keep using lists there okay so that's the reason it is very important for you to understand list you know as much as possible now I'm creating a list that is absolutely good can I have duplicate values inside a list right for example I already have ten in the list can I again have 10 in the list like this will it allow absolutely it allows no problem at all now this is a fourth list is basically having eight elements in it now in the variable panel you are seeing it has got eight elements how do I know by a command there is a command called length inside the length if you say the variable name it will tell you what is the length of the variable now if I execute this see the length of this variable is seven means there are seven elements inside that list and lest is nothing but group of values group of elements each element can be of any of the data type that we have discussed in the previous session okay as simple as that okay now the very important thing is how how do you read the list okay so let me come back here then I have so how do you read a list okay let me do it here itself I'm sorry how to read the elements in the list for example in this list I only wanted to get the data of the fourth element okay so how do I read it how do I see it on the screen only the fourth element first of all how do I read the complete variable on the screen so if I just say this you anyway XE exactly the same thing in the panel or it is equivalent to what print command both are one and the same right as we have as we know already okay now if I wanted to see the fourth element of the list see the beauty this is from this is from this is what you have to basically understand as much as possible in the braces I just say three as soon as I say three you get the fourth element see the beauty why let me explain after a few more commands if I wanted the you know if I wanted to read sixth element in the complete list what is the sixth element in the complete list hello okay here I have to say seven right I'm sorry there is a typo there is no variable right now you see class I'm sorry did I give seven okay seven is what three five six I think this is the one that you should get right did I basically miss something all right so let me try again so let me create this and then let me create let me print this why is it saying class one second okay okay I'm sorry if I have to read the sixth element so what is my sixth element one two three four five six I'm giving seven that is absolutely fine that is nothing but eight I have to say five cool so I'm getting hollow so if I have to read now you guys can basically get your answers on your own if I have to read the second element oh sorry first element I have to give zero so what does it mean DS 0 1 2 3 4 5 are the indexes index is nothing but the name given to a specific position in the list so if I have to call position number one the index value is zero position number two is index now value 1 position 3 is index value 2 so on so forth so that's the reason when I say give me the zeroth element of the list it will give you the first element if I have to tell you give me the fifth element of the list right I have to type in here as four right so now let me type in here our skill list of four right this has given me this element the fifth element so how do you read a value each element of a list you basically have to use the index numbers of the list okay now these are the indexes what is the important statement that I am trying to say indexes of list starts with zero it doesn't start with one so this is 0 this is 1 this is 2 this is 3 this is 4 etc all right now you might be getting a need of how do I read from the first element to the fourth element okay if that is your ask you have this is a syntax from the first element that is nothing but zero you have to read until the fourth element right just say five you see you get five here this is the change that you need to remember okay so if you want to need if you want to basically get five elements out of the list you basically this is nothing but exactly again 1 minus of it so 0 2 4 is nothing but 5 elements in the list if I need only four elements in the list all right zero to four right so when I say zero to four from zero zero one two three so for the upper number it is always 1 minus of it that becomes your index okay so if I have to get for example you guys can have your answer on your own if I have to get from the first element until the seventh element what should I write here I should write eight okay so from 0 0 1 2 3 4 5 6 7 until then you get the output here so in case if you want to basically get a range of numbers you basically have to specify the syntax like this with Colin as a differentiator all right so now let me also show you if I have to get the numbers from 30 to 10 what does it mean the index of this is 2 and the index of this is 4 so what should be my you know command here starting from - ok because I want until 4 right because I wanted until 4 I have to write it here as 5 so now if I come and execute this see exactly from the second element until sorry because I gave to here I'm sorry you are getting the third element because I wanted from the second element I have to write here as one not two so from the second element that is one until the five five is nothing but until four okay that's it so please remember this this will be quite confusing for the first time when you want to code but this is basic of Python programming okay if you are giving a range then upper range should be subtracted with one and that is the range of numbers that you are going to see as an output okay now you guys tell me if I have to read 40 and if I have to read these three elements what is the index should be so the starting will be 0 1 2 3 the starting should be 3 & 4 5 right 0 1 2 3 4 5 right so it should be 3 comma 6 or 3 : 6 so let's see 3 : 6 see exactly the 1 so this is how you have to practice 0 1 2 3 so from here I wanted to start so the first in the range is always 3 okay but I have to say 3 4 5 this is the upper element right I wanted to include this also in my output so I have to give range adding 1 to that index so that is my 6 okay now what if you might get a question I don't basically give any numbers I just give Colin it is exactly same asked without giving anything so there is no difference between this output and this output it's exactly one and the same all right now there is an another way to do it with it there is another way to read the data from the list so if I say from for example 1 to 7 or okay so let me do this I don't do anything but I give another Colin in the syntax and if I say 1 what does it say it is exactly the same see this syntax is a class exactly same as this in tax it's exactly same as this syntax but what happens if I replace this one with two when you replace this one with two in the complete list of the list it basically gives you every alternate number every alternate number is the syntax so first element will be printed after that the alternate number is 30 after that the alternate number is 10 after that the alternate number is oskol after that there is no alternate that's the reason you got it now instead of alternate you can also specify I wanted to see every third element in the list so I say this so you get the first element after that you get the third element from the first element after the third element again you get the third element from the 40th this is the position and after that there is no third element all right now again you can limit it in a different fashion also between only 0 and 4 that means between 0 1 2 3 that is a 1 right between this 2 3 until these four elements okay between 0 & 4 give me all turn 8 numbers so you see in all of this list if I start with 10 the next alternate number is 30 but after 30 the alternate number is 10 but I limited my range here with 0 before so I don't get anything else all right now if I say similarly Colin Colin without using if I don't use plus 1 if I say minus 1 what happens it exactly reverse the complete list first becomes class second element become or school it will come in the reverse order instead of plus one if I say minus one exactly the list order has been reversed okay so at this point of time I am only explaining you how what are the different ways you can read the elements of the list you might be wondering why and where will I use it don't worry we are going to go there later if you don't know what am i doing now I bet you you will not know how to solve the problems real-world problems in the future okay you have seen lot of read operations let's do another operations write a read on slicing operations I should call the another set of operations is can I add the first element to the second element yes absolutely you can so let me type here so operations mathematical operations right so I am sure if it is mathematical operations you can only do you can only perform honor integer values not on any other values right so I would say in the list perform zero first element you added with probably the fourth element sorry yeah three is fourth element right so what is the first element then right what is the fourth element 14 so 10 plus 40 is 50 so you can do all of these operations also like this subtraction multiplication division whatever you will you know have to do in the future okay next one for the existing list can I add a new element into the list yes there are ways to do it okay what are the different ways to add a new element to the list if I say are school adding element right so if I say are skill list for and we say plus is equals to and please add the number 250 now we see it has been done this command is nothing but this is equal and to whatever is there in the article you keep it as it is but add 250 as a list if you observe carefully if you wanted to add 250 into the existing list even that number should be in the square braces else it will throw an error okay this command is exactly the same as this command instead of you typing the variable name again after the is equals to symbol Python has given you this flexibility to use this particular symbol instead of that okay either you use this or you use this it is one and the same so not executing this and I'm showing you the output see 250 has been added in the end all right this is how you can add an element in case if you don't want to add an element somewhere here okay but you wanted to add somewhere in the second position right how do you do it so our school dot append right sorry happen I'm sorry not a pen I'm sorry I had one second I have it here I know I'm going to basically as we keep saying there's a possibility that I yeah insert is a command so insert this insert command you have to tell what position it has to insert so I have to insert in the position number two not in the big but one at the position to the index number is 1 comma what is the value now I would want to insert 300 let's see it is done now let me see say 300 has been inserted in the position number to the index of position number 2 is 1 all right because the indexes starts with 1 I mean 0 etcetera etcetera that's the reason all right now this is how you can add an element into the existing list either at the end it is as simple as this if you want to specify what position you want to insert the element you have to use insert command alright now how do you delete an element from the list I wanted to delete now I wanted to delete for example 0 1 2 3 4 5 6 7 I wanted to basically delete the 8 element in the list the index is 7 right I have multiple ways to do it one say del ask list 4 and then 8 element is nothing but 7 now if I see this it has deleted that element there is no article in the listener ok this is one way to do it another way to do it is our skill list for dot pop I say pop 3 what happens now the 4th element will go away what is my 4th element here yeah 30 will go away let now again let's print our skill list 4:30 has been gone alright if you want to delete an element this is one way to do it this is another way to do it but this way basically helps you to delete the range of you know indexes also for example I said del or skill list for from 0 to 3 that means 0 1 2 right all of them 3 numbers 10 320 all of these three will be deleted let's see now is that true yeah see 100 300 220 all of these got deleted from the list so this is another way to do it ok so we now understood what what are the different things that we have understood how to create a list how to read the elements in the list how to slice the list how to reverse the list right and we also know how to add an element into the list how to delete an element from the list right all of these operations we know and in case if you know what is the value of it and if you want to remove you can just say our skill list for right dot remove directly you can say remove Hollow from the list it will directly remove it in case if you don't want to use indexes you want to use the value names you can also directly use remove operator there all right so this is all we did and the last topic for the list by itself is you can add a list inside the list as well what does it mean now I am creating an another list called 5 I am creating elements inside the list right so I would say 10 comma 20 comma 30 comma 40 now in the fifth element I am starting another braces and in here i am saying i do' 0.5 comma au point 6 comma point 7 comma point 8 for example now i can create this list now what happens there is a list inside the upper list so this is called as nester masterless all right so if i say if i read the oscar list and if I say position number two what will I get the third element of the list right that is nothing but 30 I get 30 here we have just learnt it what if similarly I say give me you know one second give me what is this position basically the fifth element show me the fifth element of the list fifth element of the list what is that did I give some wrong okay sorry fifth element one two three four five four right so fifth element of the list is nothing but the fourth one right so I'm getting a list as an output what if I wanted to get point seven in the output I wanted to read only point seven in the output I have simple as this our skill is five the fifth element is nothing but four and just give me index number two so the index number two is point seven so you have to give one index for the parent list and another index for the child list and the outcome of this particular command should be a list only then you can pass in another index value of it so this is called as nested listing what is nested lists nested functions nested dictionaries having the same object within the another object is called as nested thing okay it's very very famous because the more complex that you write the program in your real world you're going to write a lot of molested nested objects okay this is very common in any of the programming languages okay so just to basically recollect what we have just dealt we have learned how to create a list it is also called arraign another programming languages like Java right and also in shell script etc so we know how to create a list what is the syntax how to count the number of elements in the list how to read each element of the list right how to create nested lists how to add an element into the list how to delete existing elements in the list how to delete the range of elements in the list etc so on so forth okay so with this the concept of lists is completed okay and the next topic for you is dictionary but probably I am running out of time for this session so I will try to stop here and I will be hoping to take up any questions that you guys have okay so yeah let's see that see if you want to replace you can basically say this I know what is my index number basically you want to replace this right I say what is the index number of this it is one now I would say instead of say if I directly say for example 50 now you see this is replace let me read the one now it is not as good as if you create a variable with the same name it will replace the value right it is as simple as that you see the second element has been replaced with 50 any other questions anybody yeah yes I can hear you I think you're breaking out are you partly coming in and going out your your voice is not that clear yeah you can Amin well anybody else have questions please you can please type in the chart I will take it up yes yes all of these will become the real-world problems right you basically have to get all the indexes and then for each of the index you go replace the value right thanks anybody else yeah gotough okay set of values which is a part of another list you mean right yeah it is definitely possible I would like I would like you to give a try it is definitely possible okay it is by using this remove okay just to give you a hint I have list 1 dot remove give list to whatever elements are there in list 2 those elements will be removed in list 1 yeah okay alginate numbers yeah alternate members starting from zero starting from the first one yeah what I mean by odd numbers you can basically see it is not even number or odd number don't get into that confusion odd number of feet Texas you mean you know one three five etc etc basically three five seven right yeah I think you have to write a custom program there is no direct you know feasibility with the help of these options for you you have to write a specific program like that first the way the program the way that you write a program is get the length of the list okay in that length of the list you first of all identify the odd numbers and now those odd numbers you have to pass in as an index to this command only then you will be getting it you get the work flow rate or indexes yes so I get you so what what I am trying to explain is to get the values of odd positions right or positions or indexes that's a question right did I understand right so for example my length of my you know list is basically what only four okay length off my list five it is five right first four between the number zero and five basically you will have to extract write a program program to extract from zero until the length of this whatever is the number because it should work with any program right so between these two numbers zero and this you have to extract odd numbers first so what are you basically extracting you are basically extracting the odd index is only now pass the numbers you extracted about as indexes to read those values am i clear now all right so you have to write that you know customized lines to do that job good the question that I got on the child do we use less to reveal the info or to develop a program it can be anything the list is just a group of objects in the real world you can use lists for any requirements at your mind yet so you will you will see that slowly and steadily as we progress you often use it at every stage of your programming all right any other questions please yes no all right so basically I thought I would complete lists as well as dictionaries today but good that I get ready to little slow mode and only covered the list topics and by the way whatever is there below you know the commands that I have typed all of this is only for your reference all of this I have time for you on the screen but there are a few more things that I have in the bottom you can also keep trying them and see you know just for your practice okay so I hope I've covered everything that I thought on my head to cover this list right yeah cool I think I covered yeah before even getting into dictionaries somebody has questions is it through chart okay yeah three nod this also works from one you can do it from one to anything and then see alternate this is also a way to do it three North has given you a very simple solution than me thanks three math and synth had some question yeah Sid had some question okay no you're fine great cool any other questions please all right okay thank you guys we'll cover it dictionaries in the next session that is going to be only on Monday all right thank you bye-bye
Related Videos
Agentforce NOW AMA: Build with React and Salesforce Multi-Framework
SalesforceDevs
490 views•2026-05-28
How agent o11y differs from traditional o11y — Phil Hetzel, Braintrust
aiDotEngineer
450 views•2026-05-28
WEB TECHNOLOGIES UNIT-2 | Degree 4th sem BCOM Computers web technologies unit-2 full explanation💯✅
LearnwithSahera
1K views•2026-05-29
More tests are always better? How to use AI to identify tests that bring little value
Alliance4Qualification
335 views•2026-05-29
Search Algorithms Explained in 60 Seconds! 🤖💨
samarthtuliofficial
218 views•2026-06-01
People of Game of Thrones using JavaScript DOM
AltCampus
296 views•2026-05-30
Introduction to Problem Solving Part - 1 | Lecture 1 | Intermediate DSA
ascensionix
107 views•2026-05-29
So What's Odin Lang Even Good For
TechOverTea
131 views•2026-06-01











