KwickAcademy Python · 7 min · free
Lists: Creating, Indexing, Slicing and List Operations
Learn Python lists for CBSE Class 11: create lists, index and slice them, change items, join, repeat, check, loop and copy. A list stores many values in one variable, inside square brackets; it is an ordered sequence and it is mutable.
Follows the syllabus of: CBSE Class 11 Computer Science (083), CBSE Class 11 Computer Science Essentials (083), CBSE Class 11 Informatics Practices (065), CBSE Class 12 Computer Science (083)
On screen in this lesson
What is a list?
| A list stores many values in one variable |
| Items go inside square brackets, separated by commas |
| A list is a sequence: items stay in order |
| A list is mutable: you can change its items |
A list is a row of boxes
| Item | Index | Negative index |
|---|---|---|
| "mango" | 0 | -4 |
| "banana" | 1 | -3 |
| "apple" | 2 | -2 |
| "guava" | 3 | -1 |
Quick recap
| A list is an ordered, mutable sequence in [ ] |
| Index from 0; negative index counts from the end |
| Slice [start:stop:step] never includes stop |
| + joins, * repeats, in checks membership |
| An alias shares one list; copy() or [:] makes a new one |
Quick answers
Does a slice give an IndexError when stop is past the end?
No. nums[4:100] simply gives [50, 60].
Why does changing squad also change team after squad = team?
Both names point to the same list. This is aliasing. Use team.copy() for a separate list.
KwickClips from this lesson
Short clips, one idea each. Good for revision the night before.
Is a Python list mutable?43 sec
Why does nums[1:3] give only two items?42 sec
What does [0] * 3 give?42 sec
Can a list hold other lists?42 sec
Why did the original list change?43 secThe full lesson, in text
Aarav, Sir wants a program for all forty marks in our class. Five variables typed, thirty five more to go! And marks cards come out on Monday.
Forty variables? Your fingers will give up before the program runs, yaar.
Then what now? And how do we print all forty marks?
And when a new student joins, one more variable again?
Seniors use one list for this. But the numbering inside it always trips me up.
So you don't fully know either?
The brackets part is easy. The counting part, not well enough to teach you. Let's ask Kajal Ma'am.
Good thinking, Riya. Today one list will hold all forty marks, and we will learn to create, index, slice and copy lists.
Let us start with a few new words. A list stores many values in one variable, like a shopping list on paper. We write the items inside square brackets, with a comma between them. A list is a sequence, which means the items stay in a fixed order. A list is also mutable, which simply means you can change its items after making it.
Picture a list as a row of boxes, and each box has a number called its index.
So mango is item one, at index one?
No, Riya. The first item, mango, sits in box zero, because Python starts counting from zero. Banana is in box one. Apple is in box two. Guava is in box three, and it also has index minus one, because negative indexes count from the end. Memory hook: an index is the steps from the start, and mango is zero steps away.
The single equals sign stores the list in a variable. Marks holds three numbers. Student holds a name, an age and True, so one list can mix different types. Empty is a list with nothing inside, and we can fill it later.
To get one item, write the list name, then the index inside square brackets. Fruits at zero is mango. Fruits at one is banana. Fruits at minus one is apple, the last item.
So in a list of five marks, marks at five is the fifth mark?
No, Aarav. Counting starts at zero, so the fifth mark is marks at four. Marks at five does not exist, and Python gives an IndexError.
Because a list is mutable, we can put a new value into any box. Fruits at one equals guava replaces banana with guava. The list keeps its size and order. A string is not mutable, so trying this on a string gives a type error.
A slice cuts out a part of the list and gives a new list. The colon inside the brackets separates start and stop.
So one to four gives four items, right?
No, Riya, only three. Nums from one to four gives indexes one, two and three, because the stop index is never included. Exam tip: in output questions, never include the stop. Leave out the start, and the slice begins at zero. Leave out the stop, and it runs to the end. A third number is the step, so two picks every second item. A step of minus one reverses the list.
Pause the video and predict the output of these two lines. Nums from two to two gives an empty list, because start and stop are the same. Nums from four to one hundred gives fifty and sixty. A slice never gives an index error, even when the stop is far past the end. Board exams often ask exactly this kind of output question.
The plus operator joins two lists into one new list, and this is called concatenation. Morning plus evening gives Maths, English and Hindi. The star operator repeats a list, and this is called repetition. A list with zero, star four, gives four zeros.
So a list star four makes a list four times longer?
Yes, Riya, the items repeat four times. Adding a list and a plain number, like morning plus five, gives a type error.
Membership means checking whether an item is inside a list. The in operator answers True or False. Is Anand in stops? True. Is Pune in stops? False. The not in operator asks the opposite question, so Pune not in stops is True.
Traversing means visiting every item of a list, one by one. In the first loop, the variable mark takes each mark in turn, and we print it. The second loop uses indexes instead. Len of marks is three, the number of items, so range of three gives zero, one and two.
A nested list is a list inside another list, like rows in a marks register. Each inner list holds a name and marks. Table at one is the whole second row, Aman and seventy two. Table at one, then zero, first picks the row, then the item in that row, which is Aman. Table at zero, then one, is Riya's marks, eighty five.
To traverse a nested list, loop over the rows. Row at zero is the name, and row at one is the marks. So the loop prints Riya scored eighty five, then Aman scored seventy two.
Now a common trap.
So squad is a brand new list, na?
No, Aarav. Squad equals team does not make a new list. It gives the same list a second name, and this is called aliasing. So when we change squad at zero to one hundred, team changes too. The is operator checks whether two names point to the very same list, so team is squad gives True.
To get a truly separate list, make a copy. Team dot copy gives a new list with the same items. A full slice of team, from start to end, also makes a copy. Now changing extra does not touch team, and team is extra gives False. Memory hook: equals adds a nickname, but copy makes a new list. Careful: for a nested list, copy makes a new outer list, but the inner lists are still shared.
Done! One list holds all forty marks, and one loop prints every mark.
No more forty variables? And no more typing forty print lines?
Nope. And marks at zero is the first mark, not marks at one. Zero steps from the start!
Okay, quick test. What is marks at minus one?
The last mark, eighty eight!
Forty lines became three. Now even my cricket scores are going into a list, yaar.
Let us revise what we learned today. A list is an ordered and mutable sequence written in square brackets. Indexes start from zero, and negative indexes count from the end. A slice uses start, stop and step, and the stop is never included. Plus joins lists, star repeats them, and in checks membership. Finally, a second name for the same list is only an alias, so use copy or a full slice for a real copy.
Courses that teach this
| Course | Unit |
|---|---|
| CBSE Class 10 Information Technology (402) | Digital Documentation (Advanced) using LibreOffice Writer |
| CBSE Class 9 Artificial Intelligence (417) | Part B - Unit 5: Introduction to Python |
| CBSE Class 11 Computer Science (083) | Computational Thinking and Programming - I |
| CBSE Class 11 Computer Science Essentials (083) | Computational Thinking and Programming - I |
| CBSE Class 12 Computer Science (083) | Computational Thinking and Programming – 2 |
| CBSE Class 11 Informatics Practices (065) | Introduction to Python |
| NIOS Secondary Data Entry Operations (229) | 4. Formatting Documents |
| NIOS Senior Secondary Data Entry Operations (336) | Lesson 5: Mail Merge |
| Programming All levels Python | Data Structures |
Voice-over in this lesson is AI-generated. The script is written and checked by Kajal Ma'am. Boards can revise a syllabus mid-year, so confirm anything you plan around against the official board circular. Keep your passwords, OTPs and ID numbers to yourself — we never ask for them. To reach Kajal Ma'am, use the WhatsApp button; sharing your number there is how we call you back.
Free to watch, no sign-up. Live classes with Kajal Ma'am are the paid course; these lessons stay free either way.

