Important Notice:

Course Content
List Manipulation in Python (Chapter-7) M3-R5
About Lesson
List Functions & Methods:-

                       List को operate करने के लिए python विभिन्न प्रकार के methods provide करती है।

Syntax:-                <listObject>.<method name>()

 

1. len():-

            इस function का use  list की length का पता करने के लिए किया जाता है।

a=[10,20,50]

print(len(a))                      # 3

2. count():-

            इस method का use किसी list में कोई value कितनी बार आयी है यह जानने के लिए किया जाता है।

a=[10,20,50,10,30,40,50]

print(a.count(10))                         # 2

3. append():-

          किसी लिस्ट के last में एक item जोड़ने के लिए इस method का use किया जाता है। loop का use करके append के माध्यम से एक साथ कई element को जोड़ा जा सकता है।

a=[10,15]

a.append(20)

print(a)                  # [10, 15, 20]

multiple element add

a=[]

for i in range(5):

    b=input(“Enter element “)

    a.append(b)

print(a)

 

List Functions & Methods:-

               Python provides a variety of methods to operate the list.

Syntax:-                <listObject>.<method name>()

1. len():-

                        This function is used to find the length of the list.

a=[10,20,50]

print(len(a))                      # 3

2. count():-

                        This method is used to know how many times a value appears in a list.

a=[10,20,50,10,30,40,50]

print(a.count(10))                    # 2

3. append():-

       This method is used to add an item to the last of a list. By using loop, multiple elements can be added together through append.

a=[10,15]

a.append(20)

print(a)                   # [10, 15, 20]

multiple element add

a=[]

for i in range(5):

    b=input(“Enter element “)

    a.append(b)

print(a)

error: Content is protected !!