Lists in Python - List Comprehension , List Methods in Python Part 10

Опубликовано: 06 Январь 2026
на канале: Learning With Faraz
119
11

As we are following the Python series , This is going to be the part 10 , Where are going to Learn about Lists in Python
Lists in Python is defined as the collection of zero or more object references , And lists in Python are Mutable , There it means These lists can be modified , Changed , delete elements or add elements in to it
Lists can be created using three Methods :-
1.Using list()
in order to create a list using list() method , we can pass a set , tuple or even list to this function for example
t = (1,2,3)
x= tuple(t)
This is going to convert the tuple in to a list
we can also use range function to create a List , the example of that is shown in detail in the video , therefore watch the complete video


2. Using list literals
This is very simple as follows
marks = [90 , 92, 93]

remember one more thing that list allows duplicates within itself

3.unpacking operator
but when it is called UNPACKING OPERATOR and when it is called MULT OPERATOR?
unary operator *x ---- UNPACKING
binary operator x*y --- MULT
it is used to unpack a list.
4. Using list comprehensions
Comprehensions are expressions with a LOOP and CONDITION(optional)
comp= [var_name for var_name in range(start,end)]
5.list methods
a) remove --This method takes one argument in to it where , In it you can specify an element it will remove that element from that list


i) sort -- This method is going to arrange the elements of the list in either Ascending order or descending order based on how you are going to use it,
if no arguments are provided to it , it is by default going to arrange them in the ascending order ,
if reverse= True is set then it is going to set them in the descending order
It also takes key argument which will be explained in detail in the functions video



 b) pop --- it takes an optional argument , if given it is considered as index of the list and it removes that particular element at that index postion , if no arguments are given it will remove the right most element of the list
c) clear -- it do not take any argument , it removes all the elements of list
d) copy -- create a copy of your existing list
e) index -- returns the index of the element provided as the argument
f) append -- adds an element to the right most part of the list
g) extend -- joins two lists,, a list and a tuple or list and set and so on
h) reverse -- changes the order of the list and reverses it














#Listsinpython #List #PythonCourse



Lists in Python - List Comprehension , List Methods in Python Part 10