Professional Documents
Culture Documents
LIST: INTRODUCTION
List is a fundamental data structure that serves
as a container for holding an ordered collection
of items/objects. The items of a list need not be
of same data type.
We can retrieve the elements of a list using
"index".
List can be mixture of types like numbers,
strings and other lists as well.
They are mutable which means the elements in
the list can be changed/modified
Let us consider an example:
l1= [56, 78.94, "India"]
LIST CAN BE CREATED BY TWO
WAYS
SPLIT()
We are using split() function of string, which
converts a string into list.
Abc=‘hello’
A=print(Abc.SPLIT())
Output:<class,’list’>
DIFFERENT TYPE OF LISTS
LIST OPERATIONS
MEMBERSHIP OPERATOR
REPETITION, CONCATENATION
AND EXTEND()
COMPARISON
MUTABILITY: LIST ITEMS CAN BE CHANGED
BY ASSIGNING NEW VALUES USING THE
INDEXING OPERATOR ([]).
DELETE OPERATIONS ON A LIST
TUPLES
A tuple is similar to a list in Python, but it is
immutable, meaning its elements cannot be
changed after creation, providing a fixed and
ordered collection of values. Elements of a
tuple are enclosed in parenthesis ( ).